public abstract class ClientCallStreamObserver<ReqT> extends CallStreamObserver<ReqT>
CallStreamObserverthat allows for lower-level interaction with client calls. An instance of this class is obtained via
ClientResponseObserver, or by manually casting the
StreamObserverreturned by a stub.
StreamObserver, implementations are not required to be thread-safe; if multiple
threads will be writing to an instance concurrently, the application must synchronize its calls.
DO NOT MOCK: The API is too complex to reliably mock. Use InProcessChannelBuilder to create "real" RPCs suitable for testing and make a fake for the server-side.
|Constructor and Description|
|Modifier and Type||Method and Description|
Prevent any further processing for this
Requests the peer to produce
Sets message compression for subsequent calls to
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
ClientCallStreamObserver. No further messages will be received. The server is informed of cancellations, but may not stop processing the call. Cancelling an already
ClientCallStreamObserverhas no effect.
No other methods on this class can be called after this method has been called.
It is recommended that at least one of the arguments to be non-
null, to provide
useful debug information. Both argument being null may log warnings and result in suboptimal
performance. Also note that the provided information will not be sent to the server.
message- if not
null, will appear as the description of the CANCELLED status
cause- if not
null, will appear as the cause of the CANCELLED status
public void disableAutoRequestWithInitial(int request)
StreamObserver.onNext(Object)unless it is
request()may not be called before the call is started, a number of initial requests may be specified.
This method may only be called during
public abstract boolean isReady()
true, indicates that the observer is capable of sending additional messages without requiring excessive buffering internally. This value is just a suggestion and the application is free to ignore it, however doing so may result in excessive buffering within the observer.
false, the runnable passed to
setOnReadyHandler(java.lang.Runnable) will be called after
isReady() transitions to
public abstract void setOnReadyHandler(Runnable onReadyHandler)
Runnablethat will be executed every time the stream
isReady()state changes from
true. While it is not guaranteed that the same thread will always be used to execute the
Runnable, it is guaranteed that executions are serialized with calls to the 'inbound'
May only be called during
Because there is a processing delay to deliver this notification, it is possible for
concurrent writes to cause
isReady() == false within this callback. Handle "spurious"
notifications by checking
isReady()'s current value instead of assuming it is now
isReady() == false the normal expectations apply, so there would be
public abstract void request(int count)
countmore messages to be delivered to the 'inbound'
This method is safe to call from multiple threads without external synchronization.