public abstract static class ForwardingClientCall.SimpleForwardingClientCall<ReqT,RespT> extends ForwardingClientCall<ReqT,RespT>
ForwardingClientCall
where subclasses can pass in a ClientCall
as the delegate.ForwardingClientCall.SimpleForwardingClientCall<ReqT,RespT>
ClientCall.Listener<T>
Modifier | Constructor and Description |
---|---|
protected |
SimpleForwardingClientCall(ClientCall<ReqT,RespT> delegate) |
Modifier and Type | Method and Description |
---|---|
void |
cancel(String message,
Throwable cause)
Prevent any further processing for this
ClientCall . |
protected ClientCall<ReqT,RespT> |
delegate()
Returns the delegated
ClientCall . |
Attributes |
getAttributes()
Returns additional properties of the call.
|
void |
halfClose()
Close the call for request message sending.
|
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
ClientCall.Listener.onMessage(Object) . |
void |
setMessageCompression(boolean enabled)
Enables per-message compression, if an encoding type has been negotiated.
|
String |
toString() |
sendMessage, start
protected SimpleForwardingClientCall(ClientCall<ReqT,RespT> delegate)
protected ClientCall<ReqT,RespT> delegate()
ForwardingClientCall
ClientCall
.delegate
in class ForwardingClientCall<ReqT,RespT>
public void request(int numMessages)
ClientCall
ClientCall.Listener.onMessage(Object)
. No additional messages will be delivered.
Message delivery is guaranteed to be sequential in the order received. In addition, the listener methods will not be accessed concurrently. While it is not guaranteed that the same thread will always be used, it is guaranteed that only a single thread will access the listener at a time.
If it is desired to bypass inbound flow control, a very large number of messages can be
specified (e.g. Integer.MAX_VALUE
).
If called multiple times, the number of messages able to delivered will be the sum of the calls.
This method is safe to call from multiple threads without external synchronization.
request
in class ClientCall<ReqT,RespT>
numMessages
- the requested number of messages to be delivered to the listener. Must be
non-negative.public void cancel(@Nullable String message, @Nullable Throwable cause)
ClientCall
ClientCall
. No further messages may be sent or
will be received. The server is informed of cancellations, but may not stop processing the
call. Cancellation is permitted even if previously ClientCall.halfClose()
d. Cancelling an already
cancel()
ed ClientCall
has 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.
cancel
in class ClientCall<ReqT,RespT>
message
- if not null
, will appear as the description of the CANCELLED statuscause
- if not null
, will appear as the cause of the CANCELLED statuspublic void halfClose()
ClientCall
halfClose
in class ClientCall<ReqT,RespT>
public void setMessageCompression(boolean enabled)
ClientCall
setMessageCompression
in class ClientCall<ReqT,RespT>
public boolean isReady()
ClientCall
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.
If false
, ClientCall.Listener.onReady()
will be called after isReady()
transitions to true
.
If the type of the call is either MethodDescriptor.MethodType.UNARY
or
MethodDescriptor.MethodType.SERVER_STREAMING
, this method may persistently return
false. Calls that send exactly one message should not check this method.
This abstract class's implementation always returns true
. Implementations generally
override the method.
isReady
in class ClientCall<ReqT,RespT>
public Attributes getAttributes()
ClientCall
ClientCall.Listener.onHeaders(io.grpc.Metadata)
or ClientCall.Listener.onClose(io.grpc.Status, io.grpc.Metadata)
. If called prematurely, the implementation may throw IllegalStateException
or return arbitrary Attributes
.getAttributes
in class ClientCall<ReqT,RespT>
null
attributes