• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2018 Google LLC
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
8  *     * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *     * Redistributions in binary form must reproduce the above
11  * copyright notice, this list of conditions and the following disclaimer
12  * in the documentation and/or other materials provided with the
13  * distribution.
14  *     * Neither the name of Google LLC nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 package com.google.api.gax.grpc;
31 
32 import com.google.api.gax.rpc.BatchingCallSettings;
33 import com.google.api.gax.rpc.BidiStreamingCallable;
34 import com.google.api.gax.rpc.ClientContext;
35 import com.google.api.gax.rpc.ClientStreamingCallable;
36 import com.google.api.gax.rpc.OperationCallSettings;
37 import com.google.api.gax.rpc.OperationCallable;
38 import com.google.api.gax.rpc.PagedCallSettings;
39 import com.google.api.gax.rpc.ServerStreamingCallSettings;
40 import com.google.api.gax.rpc.ServerStreamingCallable;
41 import com.google.api.gax.rpc.StreamingCallSettings;
42 import com.google.api.gax.rpc.UnaryCallSettings;
43 import com.google.api.gax.rpc.UnaryCallable;
44 import com.google.longrunning.Operation;
45 import com.google.longrunning.stub.OperationsStub;
46 
47 public interface GrpcStubCallableFactory {
48 
49   /**
50    * Create a callable object with grpc-specific functionality. Designed for use by generated code.
51    *
52    * @param grpcCallSettings the gRPC call settings
53    */
createUnaryCallable( GrpcCallSettings<RequestT, ResponseT> grpcCallSettings, UnaryCallSettings<RequestT, ResponseT> callSettings, ClientContext clientContext)54   <RequestT, ResponseT> UnaryCallable<RequestT, ResponseT> createUnaryCallable(
55       GrpcCallSettings<RequestT, ResponseT> grpcCallSettings,
56       UnaryCallSettings<RequestT, ResponseT> callSettings,
57       ClientContext clientContext);
58 
59   /**
60    * Create a paged callable object that represents a paged API method. Designed for use by
61    * generated code.
62    *
63    * @param grpcCallSettings the gRPC call settings
64    * @param pagedCallSettings {@link PagedCallSettings} to configure the paged settings with.
65    * @param clientContext {@link ClientContext} to use to connect to the service.
66    * @return {@link UnaryCallable} callable object.
67    */
68   <RequestT, ResponseT, PagedListResponseT>
createPagedCallable( GrpcCallSettings<RequestT, ResponseT> grpcCallSettings, PagedCallSettings<RequestT, ResponseT, PagedListResponseT> pagedCallSettings, ClientContext clientContext)69       UnaryCallable<RequestT, PagedListResponseT> createPagedCallable(
70           GrpcCallSettings<RequestT, ResponseT> grpcCallSettings,
71           PagedCallSettings<RequestT, ResponseT, PagedListResponseT> pagedCallSettings,
72           ClientContext clientContext);
73 
74   /**
75    * Create a callable object that represents a batching API method. Designed for use by generated
76    * code.
77    *
78    * @param grpcCallSettings the gRPC call settings
79    * @param batchingCallSettings {@link BatchingCallSettings} to configure the batching related
80    *     settings with.
81    * @param clientContext {@link ClientContext} to use to connect to the service.
82    * @return {@link UnaryCallable} callable object.
83    */
createBatchingCallable( GrpcCallSettings<RequestT, ResponseT> grpcCallSettings, BatchingCallSettings<RequestT, ResponseT> batchingCallSettings, ClientContext clientContext)84   <RequestT, ResponseT> UnaryCallable<RequestT, ResponseT> createBatchingCallable(
85       GrpcCallSettings<RequestT, ResponseT> grpcCallSettings,
86       BatchingCallSettings<RequestT, ResponseT> batchingCallSettings,
87       ClientContext clientContext);
88 
89   /**
90    * Creates a callable object that represents a long-running operation. Designed for use by
91    * generated code.
92    *
93    * @param grpcCallSettings the gRPC call settings
94    * @param operationCallSettings {@link OperationCallSettings} to configure the method-level
95    *     settings with.
96    * @param clientContext {@link ClientContext} to use to connect to the service.
97    * @param operationsStub {@link OperationsStub} to use to poll for updates on the Operation.
98    * @return {@link OperationCallable} callable object.
99    */
100   <RequestT, ResponseT, MetadataT>
createOperationCallable( GrpcCallSettings<RequestT, Operation> grpcCallSettings, OperationCallSettings<RequestT, ResponseT, MetadataT> operationCallSettings, ClientContext clientContext, OperationsStub operationsStub)101       OperationCallable<RequestT, ResponseT, MetadataT> createOperationCallable(
102           GrpcCallSettings<RequestT, Operation> grpcCallSettings,
103           OperationCallSettings<RequestT, ResponseT, MetadataT> operationCallSettings,
104           ClientContext clientContext,
105           OperationsStub operationsStub);
106 
107   /**
108    * Create a bidirectional streaming callable object with grpc-specific functionality. Designed for
109    * use by generated code.
110    *
111    * @param grpcCallSettings the gRPC call settings
112    * @param streamingCallSettings {@link StreamingCallSettings} to configure the method-level
113    *     settings with.
114    * @param clientContext {@link ClientContext} to use to connect to the service.
115    * @return {@link BidiStreamingCallable} callable object.
116    */
createBidiStreamingCallable( GrpcCallSettings<RequestT, ResponseT> grpcCallSettings, StreamingCallSettings<RequestT, ResponseT> streamingCallSettings, ClientContext clientContext)117   <RequestT, ResponseT> BidiStreamingCallable<RequestT, ResponseT> createBidiStreamingCallable(
118       GrpcCallSettings<RequestT, ResponseT> grpcCallSettings,
119       StreamingCallSettings<RequestT, ResponseT> streamingCallSettings,
120       ClientContext clientContext);
121 
122   /**
123    * Create a server-streaming callable with grpc-specific functionality. Designed for use by
124    * generated code.
125    *
126    * @param grpcCallSettings the gRPC call settings
127    * @param streamingCallSettings {@link StreamingCallSettings} to configure the method-level
128    *     settings with.
129    * @param clientContext {@link ClientContext} to use to connect to the service.
130    */
createServerStreamingCallable( GrpcCallSettings<RequestT, ResponseT> grpcCallSettings, ServerStreamingCallSettings<RequestT, ResponseT> streamingCallSettings, ClientContext clientContext)131   <RequestT, ResponseT> ServerStreamingCallable<RequestT, ResponseT> createServerStreamingCallable(
132       GrpcCallSettings<RequestT, ResponseT> grpcCallSettings,
133       ServerStreamingCallSettings<RequestT, ResponseT> streamingCallSettings,
134       ClientContext clientContext);
135 
136   /**
137    * Create a client-streaming callable object with grpc-specific functionality. Designed for use by
138    * generated code.
139    *
140    * @param grpcCallSettings the gRPC call settings
141    * @param streamingCallSettings {@link StreamingCallSettings} to configure the method-level
142    *     settings with.
143    * @param clientContext {@link ClientContext} to use to connect to the service.
144    * @return {@link ClientStreamingCallable} callable object.
145    */
createClientStreamingCallable( GrpcCallSettings<RequestT, ResponseT> grpcCallSettings, StreamingCallSettings<RequestT, ResponseT> streamingCallSettings, ClientContext clientContext)146   <RequestT, ResponseT> ClientStreamingCallable<RequestT, ResponseT> createClientStreamingCallable(
147       GrpcCallSettings<RequestT, ResponseT> grpcCallSettings,
148       StreamingCallSettings<RequestT, ResponseT> streamingCallSettings,
149       ClientContext clientContext);
150 }
151