Package io.grpc.stub
Class ClientCalls
- java.lang.Object
-
- io.grpc.stub.ClientCalls
-
public final class ClientCalls extends java.lang.ObjectUtility functions for processing different call idioms. We have one-to-one correspondence between utilities in this class and the potential signatures in a generated stub class so that the runtime can vary behavior without requiring regeneration of the stub.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <ReqT,RespT>
StreamObserver<ReqT>asyncBidiStreamingCall(ClientCall<ReqT,RespT> call, StreamObserver<RespT> responseObserver)Executes a bidirectional-streaming call.static <ReqT,RespT>
StreamObserver<ReqT>asyncClientStreamingCall(ClientCall<ReqT,RespT> call, StreamObserver<RespT> responseObserver)Executes a client-streaming call returning aStreamObserverfor the request messages.static <ReqT,RespT>
voidasyncServerStreamingCall(ClientCall<ReqT,RespT> call, ReqT req, StreamObserver<RespT> responseObserver)Executes a server-streaming call with a responseStreamObserver.static <ReqT,RespT>
voidasyncUnaryCall(ClientCall<ReqT,RespT> call, ReqT req, StreamObserver<RespT> responseObserver)Executes a unary call with a responseStreamObserver.static <ReqT,RespT>
java.util.Iterator<RespT>blockingServerStreamingCall(Channel channel, MethodDescriptor<ReqT,RespT> method, CallOptions callOptions, ReqT req)Executes a server-streaming call returning a blockingIteratorover the response stream.static <ReqT,RespT>
java.util.Iterator<RespT>blockingServerStreamingCall(ClientCall<ReqT,RespT> call, ReqT req)Executes a server-streaming call returning a blockingIteratorover the response stream.static <ReqT,RespT>
RespTblockingUnaryCall(Channel channel, MethodDescriptor<ReqT,RespT> method, CallOptions callOptions, ReqT req)Executes a unary call and blocks on the response.static <ReqT,RespT>
RespTblockingUnaryCall(ClientCall<ReqT,RespT> call, ReqT req)Executes a unary call and blocks on the response.static <ReqT,RespT>
com.google.common.util.concurrent.ListenableFuture<RespT>futureUnaryCall(ClientCall<ReqT,RespT> call, ReqT req)Executes a unary call and returns aListenableFutureto the response.
-
-
-
Method Detail
-
asyncUnaryCall
public static <ReqT,RespT> void asyncUnaryCall(ClientCall<ReqT,RespT> call, ReqT req, StreamObserver<RespT> responseObserver)
Executes a unary call with a responseStreamObserver. Thecallshould not be already started. After calling this method,callshould no longer be used.If the provided
responseObserveris an instance ofClientResponseObserver,beforeStart()will be called.
-
asyncServerStreamingCall
public static <ReqT,RespT> void asyncServerStreamingCall(ClientCall<ReqT,RespT> call, ReqT req, StreamObserver<RespT> responseObserver)
Executes a server-streaming call with a responseStreamObserver. Thecallshould not be already started. After calling this method,callshould no longer be used.If the provided
responseObserveris an instance ofClientResponseObserver,beforeStart()will be called.
-
asyncClientStreamingCall
public static <ReqT,RespT> StreamObserver<ReqT> asyncClientStreamingCall(ClientCall<ReqT,RespT> call, StreamObserver<RespT> responseObserver)
Executes a client-streaming call returning aStreamObserverfor the request messages. Thecallshould not be already started. After calling this method,callshould no longer be used.If the provided
responseObserveris an instance ofClientResponseObserver,beforeStart()will be called.- Returns:
- request stream observer. It will extend
ClientCallStreamObserver
-
asyncBidiStreamingCall
public static <ReqT,RespT> StreamObserver<ReqT> asyncBidiStreamingCall(ClientCall<ReqT,RespT> call, StreamObserver<RespT> responseObserver)
Executes a bidirectional-streaming call. Thecallshould not be already started. After calling this method,callshould no longer be used.If the provided
responseObserveris an instance ofClientResponseObserver,beforeStart()will be called.- Returns:
- request stream observer. It will extend
ClientCallStreamObserver
-
blockingUnaryCall
public static <ReqT,RespT> RespT blockingUnaryCall(ClientCall<ReqT,RespT> call, ReqT req)
Executes a unary call and blocks on the response. Thecallshould not be already started. After calling this method,callshould no longer be used.- Returns:
- the single response message.
- Throws:
StatusRuntimeException- on error
-
blockingUnaryCall
public static <ReqT,RespT> RespT blockingUnaryCall(Channel channel, MethodDescriptor<ReqT,RespT> method, CallOptions callOptions, ReqT req)
Executes a unary call and blocks on the response. Thecallshould not be already started. After calling this method,callshould no longer be used.- Returns:
- the single response message.
- Throws:
StatusRuntimeException- on error
-
blockingServerStreamingCall
public static <ReqT,RespT> java.util.Iterator<RespT> blockingServerStreamingCall(ClientCall<ReqT,RespT> call, ReqT req)
Executes a server-streaming call returning a blockingIteratorover the response stream. Thecallshould not be already started. After calling this method,callshould no longer be used.The returned iterator may throw
StatusRuntimeExceptionon error.- Returns:
- an iterator over the response stream.
-
blockingServerStreamingCall
public static <ReqT,RespT> java.util.Iterator<RespT> blockingServerStreamingCall(Channel channel, MethodDescriptor<ReqT,RespT> method, CallOptions callOptions, ReqT req)
Executes a server-streaming call returning a blockingIteratorover the response stream. Thecallshould not be already started. After calling this method,callshould no longer be used.The returned iterator may throw
StatusRuntimeExceptionon error.- Returns:
- an iterator over the response stream.
-
futureUnaryCall
public static <ReqT,RespT> com.google.common.util.concurrent.ListenableFuture<RespT> futureUnaryCall(ClientCall<ReqT,RespT> call, ReqT req)
Executes a unary call and returns aListenableFutureto the response. Thecallshould not be already started. After calling this method,callshould no longer be used.- Returns:
- a future for the single response message.
-
-