Class UnaryGrpcFuture<ReqT,RespT,V>

java.lang.Object
io.deephaven.client.impl.UnaryGrpcFuture<ReqT,RespT,V>
Type Parameters:
ReqT - The type of the gRPC request
RespT - The type of the gRPC response
V - 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 Details

    • of

      public 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.
      Type Parameters:
      ReqT - The type of the gRPC request
      RespT - The type of the gRPC response
      V - The type of the result to make available in the future
      Parameters:
      request - the gRPC request value
      call - the unary gRPC call reference/lambda
      mapping - 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 request
      RespT - The type of the gRPC response
      Parameters:
      request - the gRPC request value
      call - the unary gRPC call reference/lambda
      Returns:
      a CompletableFuture that will succeed, fail, or be canceled, but won't contain a value
    • future

      public CompletableFuture<V> future()
    • beforeStart

      public void beforeStart(io.grpc.stub.ClientCallStreamObserver<ReqT> requestStream)
      Specified by:
      beforeStart in interface io.grpc.stub.ClientResponseObserver<ReqT,RespT>
    • onNext

      public void onNext(RespT value)
      Specified by:
      onNext in interface io.grpc.stub.StreamObserver<ReqT>
    • onError

      public void onError(Throwable t)
      Specified by:
      onError in interface io.grpc.stub.StreamObserver<ReqT>
    • onCompleted

      public void onCompleted()
      Specified by:
      onCompleted in interface io.grpc.stub.StreamObserver<ReqT>