Imported Upstream version 1.20.1
[platform/upstream/grpc.git] / src / csharp / Grpc.Core.Api / CallInvoker.cs
1 #region Copyright notice and license
2
3 // Copyright 2015-2016 gRPC authors.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16
17 #endregion
18
19 using System.Threading.Tasks;
20
21 namespace Grpc.Core
22 {
23     /// <summary>
24     /// Abstraction of client-side RPC invocation.
25     /// </summary>
26     public abstract class CallInvoker
27     {
28         /// <summary>
29         /// Invokes a simple remote call in a blocking fashion.
30         /// </summary>
31         public abstract TResponse BlockingUnaryCall<TRequest, TResponse>(Method<TRequest, TResponse> method, string host, CallOptions options, TRequest request)
32             where TRequest : class
33             where TResponse : class;
34
35         /// <summary>
36         /// Invokes a simple remote call asynchronously.
37         /// </summary>
38         public abstract AsyncUnaryCall<TResponse> AsyncUnaryCall<TRequest, TResponse>(Method<TRequest, TResponse> method, string host, CallOptions options, TRequest request)
39             where TRequest : class
40             where TResponse : class;
41
42         /// <summary>
43         /// Invokes a server streaming call asynchronously.
44         /// In server streaming scenario, client sends on request and server responds with a stream of responses.
45         /// </summary>
46         public abstract AsyncServerStreamingCall<TResponse> AsyncServerStreamingCall<TRequest, TResponse>(Method<TRequest, TResponse> method, string host, CallOptions options, TRequest request)
47             where TRequest : class
48             where TResponse : class;
49
50         /// <summary>
51         /// Invokes a client streaming call asynchronously.
52         /// In client streaming scenario, client sends a stream of requests and server responds with a single response.
53         /// </summary>
54         public abstract AsyncClientStreamingCall<TRequest, TResponse> AsyncClientStreamingCall<TRequest, TResponse>(Method<TRequest, TResponse> method, string host, CallOptions options)
55             where TRequest : class
56             where TResponse : class;
57
58         /// <summary>
59         /// Invokes a duplex streaming call asynchronously.
60         /// In duplex streaming scenario, client sends a stream of requests and server responds with a stream of responses.
61         /// The response stream is completely independent and both side can be sending messages at the same time.
62         /// </summary>
63         public abstract AsyncDuplexStreamingCall<TRequest, TResponse> AsyncDuplexStreamingCall<TRequest, TResponse>(Method<TRequest, TResponse> method, string host, CallOptions options)
64             where TRequest : class
65             where TResponse : class;
66     }
67 }