Interface UmaDbStreamObserver<T>
- Type Parameters:
T- the type of value delivered, e.g.ReadResponseorSubscribeResponse
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 TypeMethodDescriptionvoidInvoked when the server has closed the stream normally.voidonError(UmaDbException error) Invoked when the stream fails.voidInvoked for each batch delivered by the server.default voidonStart(UmaDbStream stream) Invoked once, before the stream starts and before any value is delivered.
-
Method Details
-
onStart
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. CallUmaDbStream.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
-
onError
Invoked when the stream fails. Terminal.- Parameters:
error- the failure, already translated into theUmaDbExceptionhierarchy
-
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 afterUmaDbStream.cancel()or a shutdown.
-