Interface UmaDbStreamObserver<T>

Type Parameters:
T - the type of value delivered, e.g. ReadResponse or SubscribeResponse

public interface UmaDbStreamObserver<T>
Receives the events of an asynchronous server stream.

Signal ordering

For any one stream the callbacks are invoked in order and never concurrently: onStart(UmaDbStream) first, then zero or more onNext(Object), then exactly one terminal signal — either onCompleted() or onError(UmaDbException), never both.

Threading

Callbacks are invoked on a gRPC callback thread. Do not block and do not perform long-running work in them: doing so holds up the stream and occupies a thread from the channel's executor. Hand work off to your own executor if it is not trivial. Note that blocking on another UmaDB call from inside a callback risks deadlock if the channel's executor is saturated.

An exception thrown from onNext(Object) cancels the stream and is reported back through onError(UmaDbException).

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Invoked when the server has closed the stream normally.
    void
    Invoked when the stream fails.
    void
    onNext(T value)
    Invoked for each batch delivered by the server.
    default void
    Invoked once, before the stream starts and before any value is delivered.
  • Method Details

    • onStart

      default void onStart(UmaDbStream stream)
      Invoked once, before the stream starts and before any value is delivered.

      This is the only place where initial demand can be set, which is why it exists: by the time the opening call returns its UmaDbStream, values may already have arrived. Call UmaDbStream.request(long) here to run the stream in pull mode; do nothing to accept the default push mode.

      Parameters:
      stream - the handle for controlling this stream
    • onNext

      void onNext(T value)
      Invoked for each batch delivered by the server.
      Parameters:
      value - the batch
    • onError

      void onError(UmaDbException error)
      Invoked when the stream fails. Terminal.
      Parameters:
      error - the failure, already translated into the UmaDbException hierarchy
    • onCompleted

      void onCompleted()
      Invoked when the server has closed the stream normally. Terminal.

      A subscription opened with UmaDbAsyncClient.subscribe(SubscribeRequest, UmaDbStreamObserver) does not end on its own, so in practice this fires only after UmaDbStream.cancel() or a shutdown.