Interface ServerCallHandler<RequestT,ResponseT>
-
@ThreadSafe public interface ServerCallHandler<RequestT,ResponseT>
Interface to initiate processing of incoming remote calls. Advanced applications and generated code will implement this interface to allowsServer
s to invoke service methods.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ServerCall.Listener<RequestT>
startCall(ServerCall<RequestT,ResponseT> call, Metadata headers)
Starts asynchronous processing of an incoming call.
-
-
-
Method Detail
-
startCall
ServerCall.Listener<RequestT> startCall(ServerCall<RequestT,ResponseT> call, Metadata headers)
Starts asynchronous processing of an incoming call.Callers of this method transfer their ownership of the non-thread-safe
ServerCall
andMetadata
arguments to theServerCallHandler
implementation for processing. Ownership means that the implementation may invoke methods oncall
andheaders
whilestartCall(io.grpc.ServerCall<RequestT, ResponseT>, io.grpc.Metadata)
runs and at any time after it returns normally. On the other hand, ifstartCall(io.grpc.ServerCall<RequestT, ResponseT>, io.grpc.Metadata)
throws, ownership ofcall
andheaders
reverts to the caller and the implementation loses the right to call methods on these objects (from some other thread, say).Ownership also includes the responsibility to eventually close
call
. In particular, ifstartCall(io.grpc.ServerCall<RequestT, ResponseT>, io.grpc.Metadata)
throws an exception, the caller must handle it by closingcall
with an error. Sincecall
can only be closed once, an implementation can report errors either toServerCall.close(io.grpc.Status, io.grpc.Metadata)
for itself or by throwing an exception, but not both.Returns a non-
null
listener for the incoming call. Callers of this method must arrange for events associated withcall
to be delivered there.- Parameters:
call
- object for responding to the remote client.headers
- request headers received from the client but open to modification by an owner- Returns:
- listener for processing incoming request messages for
call
-
-