Class ForwardingServerCall<ReqT,RespT>
- java.lang.Object
-
- io.grpc.ServerCall<ReqT,RespT>
-
- io.grpc.ForwardingServerCall<ReqT,RespT>
-
- Direct Known Subclasses:
ForwardingServerCall.SimpleForwardingServerCall
public abstract class ForwardingServerCall<ReqT,RespT> extends ServerCall<ReqT,RespT>
AServerCallwhich forwards all of its methods to anotherServerCall.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classForwardingServerCall.SimpleForwardingServerCall<ReqT,RespT>A simplified version ofForwardingServerCallwhere subclasses can pass in aServerCallas the delegate.-
Nested classes/interfaces inherited from class io.grpc.ServerCall
ServerCall.Listener<ReqT>
-
-
Constructor Summary
Constructors Constructor Description ForwardingServerCall()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclose(Status status, Metadata trailers)Close the call with the provided status.protected abstract ServerCall<ReqT,RespT>delegate()Returns the delegatedServerCall.AttributesgetAttributes()Returns properties of a single call.StringgetAuthority()Gets the authority this call is addressed to.MethodDescriptor<ReqT,RespT>getMethodDescriptor()TheMethodDescriptorfor the call.SecurityLevelgetSecurityLevel()Returns the level of security guarantee in communicationsbooleanisCancelled()Returnstruewhen 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.booleanisReady()Iftrue, indicates that the call is capable of sending additional messages without requiring excessive buffering internally.voidrequest(int numMessages)Requests up to the given number of messages from the call to be delivered toServerCall.Listener.onMessage(Object).voidsendHeaders(Metadata headers)Send response header metadata prior to sending a response message.voidsendMessage(RespT message)Send a response message.voidsetCompression(String compressor)Sets the compression algorithm for this call.voidsetMessageCompression(boolean enabled)Enables per-message compression, if an encoding type has been negotiated.voidsetOnReadyThreshold(int numBytes)A hint to the call that specifies how many bytes must be queued beforeServerCall.isReady()will return false.StringtoString()
-
-
-
Method Detail
-
delegate
protected abstract ServerCall<ReqT,RespT> delegate()
Returns the delegatedServerCall.
-
sendMessage
public void sendMessage(RespT message)
Description copied from class:ServerCallSend a response message. Messages are the primary form of communication associated with RPCs. Multiple response messages may exist for streaming calls.- Specified by:
sendMessagein classServerCall<ReqT,RespT>- Parameters:
message- response message.
-
getMethodDescriptor
public MethodDescriptor<ReqT,RespT> getMethodDescriptor()
Description copied from class:ServerCallTheMethodDescriptorfor the call.- Specified by:
getMethodDescriptorin classServerCall<ReqT,RespT>
-
request
public void request(int numMessages)
Description copied from class:ServerCallRequests up to the given number of messages from the call to be delivered toServerCall.Listener.onMessage(Object). OncenumMessageshave 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.
This method is safe to call from multiple threads without external synchronization.
- Specified by:
requestin classServerCall<ReqT,RespT>- Parameters:
numMessages- the requested number of messages to be delivered to the listener.
-
sendHeaders
public void sendHeaders(Metadata headers)
Description copied from class:ServerCallSend response header metadata prior to sending a response message. This method may only be called once and cannot be called after calls toServerCall.sendMessage(RespT)orServerCall.close(io.grpc.Status, io.grpc.Metadata).Since
Metadatais not thread-safe, the caller must not access (read or write)headersafter this point.- Specified by:
sendHeadersin classServerCall<ReqT,RespT>- Parameters:
headers- metadata to send prior to any response body.
-
isReady
public boolean isReady()
Description copied from class:ServerCallIftrue, 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,ServerCall.Listener.onReady()will be called afterisReady()transitions totrue.This abstract class's implementation always returns
true. Implementations generally override the method.- Overrides:
isReadyin classServerCall<ReqT,RespT>
-
close
public void close(Status status, Metadata trailers)
Description copied from class:ServerCallClose the call with the provided status. No further sending or receiving will occur. IfStatus.isOk()isfalse, then the call is said to have failed.If no errors or cancellations are known to have occurred, then a
ServerCall.Listener.onComplete()notification should be expected, independent ofstatus. OtherwiseServerCall.Listener.onCancel()has been or will be called.Since
Metadatais not thread-safe, the caller must not access (read or write)trailersafter this point.This method implies the caller completed processing the RPC, but it does not imply the RPC is complete. The call implementation will need additional time to complete the RPC and during this time the client is still able to cancel the request or a network error might cause the RPC to fail. If you wish to know when the call is actually completed/closed, you have to use
ServerCall.Listener.onComplete()orServerCall.Listener.onCancel()instead. This method is not necessarily invoked when Listener.onCancel() is called.- Specified by:
closein classServerCall<ReqT,RespT>
-
isCancelled
public boolean isCancelled()
Description copied from class:ServerCallReturnstruewhen 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.
- Specified by:
isCancelledin classServerCall<ReqT,RespT>
-
setMessageCompression
public void setMessageCompression(boolean enabled)
Description copied from class:ServerCallEnables per-message compression, if an encoding type has been negotiated. If no message encoding has been negotiated, this is a no-op. By default per-message compression is enabled, but may not have any effect if compression is not enabled on the call.- Overrides:
setMessageCompressionin classServerCall<ReqT,RespT>
-
setOnReadyThreshold
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/11021") public void setOnReadyThreshold(int numBytes)
Description copied from class:ServerCallA hint to the call that specifies how many bytes must be queued beforeServerCall.isReady()will return false. A call may ignore this property if unsupported. This may only be set before any messages are sent.- Overrides:
setOnReadyThresholdin classServerCall<ReqT,RespT>- Parameters:
numBytes- The number of bytes that must be queued. Must be a positive integer.
-
setCompression
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1704") public void setCompression(String compressor)
Description copied from class:ServerCallSets the compression algorithm for this call. This compression is utilized for sending. If the server does not support the compression algorithm, the call will fail. This method may only be called beforeServerCall.sendHeaders(io.grpc.Metadata). The compressor to use will be looked up in theCompressorRegistry. Default gRPC servers support the "gzip" compressor.It is safe to call this even if the client does not support the compression format chosen. The implementation will handle negotiation with the client and may fall back to no compression.
- Overrides:
setCompressionin classServerCall<ReqT,RespT>- Parameters:
compressor- the name of the compressor to use.
-
getAttributes
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1779") public Attributes getAttributes()
Description copied from class:ServerCallReturns properties of a single call.Attributes originate from the transport and can be altered by
ServerTransportFilter.- Overrides:
getAttributesin classServerCall<ReqT,RespT>- Returns:
- non-
nullAttributes container
-
getAuthority
public String getAuthority()
Description copied from class:ServerCallGets the authority this call is addressed to.- Overrides:
getAuthorityin classServerCall<ReqT,RespT>- Returns:
- the authority string.
nullif not available.
-
getSecurityLevel
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/4692") public SecurityLevel getSecurityLevel()
Description copied from class:ServerCallReturns the level of security guarantee in communicationsDetermining the level of security offered by the transport for RPCs on server-side. This can be approximated by looking for the SSLSession, but that doesn't work for ALTS and maybe some future TLS approaches. May return a lower security level when it cannot be determined precisely.
- Overrides:
getSecurityLevelin classServerCall<ReqT,RespT>- Returns:
- non-
nullSecurityLevel enum
-
-