@ExperimentalApi(value="https://github.com/grpc/grpc-java/issues/1788") @DoNotMock public abstract class CallStreamObserver<V> extends Object implements StreamObserver<V>
In any call there are logically two StreamObserver
implementations:
Implementations of this class represent the 'outbound' message stream.
Like 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.
Constructor and Description |
---|
CallStreamObserver() |
Modifier and Type | Method and Description |
---|---|
abstract void |
disableAutoInboundFlowControl()
Disables automatic flow control where a token is returned to the peer after a call
to the 'inbound'
StreamObserver.onNext(Object) has completed. |
abstract boolean |
isReady()
If
true , indicates that the observer is capable of sending additional messages
without requiring excessive buffering internally. |
abstract void |
request(int count)
Requests the peer to produce
count more messages to be delivered to the 'inbound'
StreamObserver . |
abstract void |
setMessageCompression(boolean enable)
Sets message compression for subsequent calls to
StreamObserver.onNext(V) . |
abstract void |
setOnReadyHandler(Runnable onReadyHandler)
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
onCompleted, onError, onNext
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.public abstract void setOnReadyHandler(Runnable onReadyHandler)
Runnable
that will be executed every time the stream isReady()
state
changes from false
to 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' StreamObserver
.
On client-side this method may only be called during ClientResponseObserver.beforeStart(io.grpc.stub.ClientCallStreamObserver<ReqT>)
. On server-side it may only be called during the initial
call to the application, before the service returns its StreamObserver
.
Note that the handler may be called some time after isReady()
has transitioned to
true as other callbacks may still be executing in the 'inbound' observer.
onReadyHandler
- to call when peer is ready to receive more messages.public abstract void disableAutoInboundFlowControl()
StreamObserver.onNext(Object)
has completed. If disabled
an application must make explicit calls to request(int)
to receive messages.
On client-side this method may only be called during ClientResponseObserver.beforeStart(io.grpc.stub.ClientCallStreamObserver<ReqT>)
. On server-side it may only be called during the initial
call to the application, before the service returns its StreamObserver
.
Note that for cases where the runtime knows that only one inbound message is allowed calling this method will have no effect and the runtime will always permit one and only one message. This is true for:
MethodDescriptor.MethodType.UNARY
operations on both the
client and server.
MethodDescriptor.MethodType.CLIENT_STREAMING
operations on the server.
MethodDescriptor.MethodType.SERVER_STREAMING
operations on the client.
public abstract void request(int count)
count
more messages to be delivered to the 'inbound'
StreamObserver
.
This method is safe to call from multiple threads without external synchronization.
count
- more messagespublic abstract void setMessageCompression(boolean enable)
StreamObserver.onNext(V)
.enable
- whether to enable compression.