Package io.deephaven.client.impl
Class UnaryGrpcFuture<ReqT,RespT,V>
java.lang.Object
io.deephaven.client.impl.UnaryGrpcFuture<ReqT,RespT,V>
- Type Parameters:
ReqT- The type of the gRPC requestRespT- The type of the gRPC responseV- The type of the result to make available in the future
- All Implemented Interfaces:
io.grpc.stub.ClientResponseObserver<ReqT,,RespT> io.grpc.stub.StreamObserver<RespT>
public class UnaryGrpcFuture<ReqT,RespT,V>
extends Object
implements io.grpc.stub.ClientResponseObserver<ReqT,RespT>
ClientResponseObserver implementation that can map results into a CompletableFuture. To keep generics under control,
has two factory methods,
of(Object, BiConsumer, Function) and ignoreResponse(Object, BiConsumer).-
Method Summary
Modifier and TypeMethodDescriptionvoidbeforeStart(io.grpc.stub.ClientCallStreamObserver<ReqT> requestStream) future()static <ReqT,RespT>
CompletableFuture<Void>ignoreResponse(ReqT request, BiConsumer<ReqT, io.grpc.stub.StreamObserver<RespT>> call) Factory method to take a request instance and a method reference to a unary call.static <ReqT,RespT, V>
CompletableFuture<V>of(ReqT request, BiConsumer<ReqT, io.grpc.stub.StreamObserver<RespT>> call, Function<RespT, V> mapping) Factory method to take a request instance, a method reference to a unary call, and a mapping function to transform the result before supplying it to the future.voidvoidvoid
-
Method Details
-
of
public static <ReqT,RespT, CompletableFuture<V> ofV> (ReqT request, BiConsumer<ReqT, io.grpc.stub.StreamObserver<RespT>> call, Function<RespT, V> mapping) Factory method to take a request instance, a method reference to a unary call, and a mapping function to transform the result before supplying it to the future.- Type Parameters:
ReqT- The type of the gRPC requestRespT- The type of the gRPC responseV- The type of the result to make available in the future- Parameters:
request- the gRPC request valuecall- the unary gRPC call reference/lambdamapping- a mapping function to transform the response into a result- Returns:
- A CompletableFuture that will succeed, fail, or be canceled. If it succeeds, will contain a result from the mapping function.
-
ignoreResponse
public static <ReqT,RespT> CompletableFuture<Void> ignoreResponse(ReqT request, BiConsumer<ReqT, io.grpc.stub.StreamObserver<RespT>> call) Factory method to take a request instance and a method reference to a unary call. Returns a void completablefuture, as many gRPC calls in Deephaven have no meaningful result, except for the fact that they succeeded and server-side state has been modified.- Type Parameters:
ReqT- The type of the gRPC requestRespT- The type of the gRPC response- Parameters:
request- the gRPC request valuecall- the unary gRPC call reference/lambda- Returns:
- a CompletableFuture that will succeed, fail, or be canceled, but won't contain a value
-
future
-
beforeStart
-
onNext
- Specified by:
onNextin interfaceio.grpc.stub.StreamObserver<ReqT>
-
onError
- Specified by:
onErrorin interfaceio.grpc.stub.StreamObserver<ReqT>
-
onCompleted
public void onCompleted()- Specified by:
onCompletedin interfaceio.grpc.stub.StreamObserver<ReqT>
-