/** * Executes a server-streaming call with a response {@link StreamObserver}. */ public static <ReqT, RespT> void asyncServerStreamingCall( ClientCall<ReqT, RespT> call, ReqT param, StreamObserver<RespT> responseObserver) { asyncUnaryRequestCall(call, param, responseObserver, true); }
/** * Executes a unary call with a response {@link StreamObserver}. */ public static <ReqT, RespT> void asyncUnaryCall( ClientCall<ReqT, RespT> call, ReqT param, StreamObserver<RespT> observer) { asyncUnaryRequestCall(call, param, observer, false); }
/** * Executes a unary call and returns a {@link ListenableFuture} to the response. * * @return a future for the single response message. */ public static <ReqT, RespT> ListenableFuture<RespT> futureUnaryCall( ClientCall<ReqT, RespT> call, ReqT param) { GrpcFuture<RespT> responseFuture = new GrpcFuture<RespT>(call); asyncUnaryRequestCall(call, param, new UnaryStreamToFuture<RespT>(responseFuture), false); return responseFuture; }
/** * Executes a server-streaming call returning a blocking {@link Iterator} over the * response stream. * @return an iterator over the response stream. */ // TODO(louiscryan): Not clear if we want to use this idiom for 'simple' stubs. public static <ReqT, RespT> Iterator<RespT> blockingServerStreamingCall( ClientCall<ReqT, RespT> call, ReqT param) { BlockingResponseStream<RespT> result = new BlockingResponseStream<RespT>(call); asyncUnaryRequestCall(call, param, result.listener(), true); return result; }
private static <ReqT, RespT> void asyncUnaryRequestCall( ClientCall<ReqT, RespT> call, ReqT param, StreamObserver<RespT> responseObserver, boolean streamingResponse) { asyncUnaryRequestCall( call, param, new StreamObserverToCallListenerAdapter<ReqT, RespT>( responseObserver, new CallToStreamObserverAdapter<ReqT>(call), streamingResponse), streamingResponse); }
/** * Executes a server-streaming call returning a blocking {@link Iterator} over the * response stream. * * @return an iterator over the response stream. */ // TODO(louiscryan): Not clear if we want to use this idiom for 'simple' stubs. public static <ReqT, RespT> Iterator<RespT> blockingServerStreamingCall( Channel channel, MethodDescriptor<ReqT, RespT> method, CallOptions callOptions, ReqT param) { ThreadlessExecutor executor = new ThreadlessExecutor(); ClientCall<ReqT, RespT> call = channel.newCall(method, callOptions.withExecutor(executor)); BlockingResponseStream<RespT> result = new BlockingResponseStream<RespT>(call, executor); asyncUnaryRequestCall(call, param, result.listener(), true); return result; }