aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/csharp/GrpcCore/Call.cs
blob: 66e70041805cc5a2543411f41789a9614a46e586 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using System;
using Google.GRPC.Core.Internal;

namespace Google.GRPC.Core
{
    public class Call<TRequest, TResponse>
    {
        readonly string methodName;
        readonly Func<TRequest, byte[]> requestSerializer;
        readonly Func<byte[], TResponse> responseDeserializer;
        readonly Channel channel;

        public Call(string methodName, 
                    Func<TRequest, byte[]> requestSerializer,
                    Func<byte[], TResponse> responseDeserializer,
                    TimeSpan timeout,
                    Channel channel) {
            this.methodName = methodName;
            this.requestSerializer = requestSerializer;
            this.responseDeserializer = responseDeserializer;
            this.channel = channel;
        }

        public Call(Method<TRequest, TResponse> method, Channel channel)
        {
            this.methodName = method.Name;
            this.requestSerializer = method.RequestMarshaller.Serializer;
            this.responseDeserializer = method.ResponseMarshaller.Deserializer;
            this.channel = channel;
        }

        public Channel Channel
        {
            get
            {
                return this.channel;
            }
        }

        public string MethodName
        {
            get
            {
                return this.methodName;
            }
        }

        public Func<TRequest, byte[]> RequestSerializer
        {
            get
            {
                return this.requestSerializer;
            }
        }

        public Func<byte[], TResponse> ResponseDeserializer
        {
            get
            {
                return this.responseDeserializer;
            }
        }
    }
}