public abstract class ForwardingServerCall<RespT> extends ServerCall<RespT>
ServerCall
which forwards all of it's methods to another ServerCall
.Modifier and Type | Class and Description |
---|---|
static class |
ForwardingServerCall.SimpleForwardingServerCall<RespT>
A simplified version of
ForwardingServerCall where subclasses can pass in a ServerCall as the delegate. |
ServerCall.Listener<RequestT>
Constructor and Description |
---|
ForwardingServerCall() |
Modifier and Type | Method and Description |
---|---|
void |
close(Status status,
Metadata.Trailers trailers)
Close the call with the provided status.
|
protected abstract ServerCall<RespT> |
delegate()
Returns the delegated
ServerCall . |
boolean |
isCancelled()
Returns
true when the call is cancelled and the server is encouraged to abort
processing to save resources, since the client will not be processing any further methods. |
boolean |
isReady()
If
true , indicates that the call is capable of sending additional messages
without requiring excessive buffering internally. |
void |
request(int numMessages)
Requests up to the given number of messages from the call to be delivered to
ServerCall.Listener.onPayload(Object) . |
void |
sendHeaders(Metadata.Headers headers)
Send response header metadata prior to sending a response payload.
|
void |
sendPayload(RespT payload)
Send a response message.
|
protected abstract ServerCall<RespT> delegate()
ServerCall
.public void request(int numMessages)
ServerCall
ServerCall.Listener.onPayload(Object)
. Once numMessages
have been delivered
no further request messages will be delivered until more messages are requested by
calling this method again.
Servers use this mechanism to provide back-pressure to the client for flow-control.
request
in class ServerCall<RespT>
numMessages
- the requested number of messages to be delivered to the listener.public void sendHeaders(Metadata.Headers headers)
ServerCall
Stream#sendPayload
or #close
.sendHeaders
in class ServerCall<RespT>
headers
- metadata to send prior to any response body.public void sendPayload(RespT payload)
ServerCall
sendPayload
in class ServerCall<RespT>
payload
- response message.public boolean isReady()
ServerCall
true
, indicates that the call is capable of sending additional messages
without requiring excessive buffering internally. This event is
just a suggestion and the application is free to ignore it, however doing so may
result in excessive buffering within the call.
This implementation always returns true
.
isReady
in class ServerCall<RespT>
public void close(Status status, Metadata.Trailers trailers)
ServerCall
status
is not equal to Status.OK
, then the call is said to have failed.
If status
is not Status.CANCELLED
and no errors or cancellations are known
to have occured, then a ServerCall.Listener.onComplete()
notification should be expected.
Otherwise ServerCall.Listener.onCancel()
has been or will be called.
close
in class ServerCall<RespT>
public boolean isCancelled()
ServerCall
true
when the call is cancelled and the server is encouraged to abort
processing to save resources, since the client will not be processing any further methods.
Cancellations can be caused by timeouts, explicit cancel by client, network errors, and
similar.
This method may safely be called concurrently from multiple threads.
isCancelled
in class ServerCall<RespT>