Class GrpcServiceClient.SingleValueStreamObserver<T>

Type Parameters:
T - The type of objects received in this stream.
All Implemented Interfaces:
Enclosing class:

public static class GrpcServiceClient.SingleValueStreamObserver<T> extends Object implements io.grpc.stub.StreamObserver<T>
A simple StreamObserver adapter class that completes a CompletableFuture when the observer is completed.

This observer uses the value passed to its onNext(Object) method to complete the CompletableFuture.

This observer should only be used in cases where a single result is expected. If more that one call is made to onNext(Object) then future will be completed with an exception.

  • Constructor Details

    • SingleValueStreamObserver

      public SingleValueStreamObserver()
      Create a SingleValueStreamObserver.
  • Method Details

    • completionStage

      public CompletionStage<T> completionStage()
      Obtain the CompletableFuture that will be completed when the StreamObserver completes.
      The CompletableFuture
    • onNext

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

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

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