@ThreadSafe public interface ServerCallHandler<RequestT,ResponseT>
Server
s to invoke service methods.Modifier and Type | Method and Description |
---|---|
ServerCall.Listener<RequestT> |
startCall(ServerCall<RequestT,ResponseT> call,
Metadata headers)
Starts asynchronous processing of an incoming call.
|
ServerCall.Listener<RequestT> startCall(ServerCall<RequestT,ResponseT> call, Metadata headers)
Callers of this method transfer their ownership of the non-thread-safe ServerCall
and Metadata
arguments to the ServerCallHandler
implementation for processing.
Ownership means that the implementation may invoke methods on call
and headers
while startCall(io.grpc.ServerCall<RequestT, ResponseT>, io.grpc.Metadata)
runs and at any time after it returns normally. On the other hand, if
startCall(io.grpc.ServerCall<RequestT, ResponseT>, io.grpc.Metadata)
throws, ownership of call
and headers
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,
if startCall(io.grpc.ServerCall<RequestT, ResponseT>, io.grpc.Metadata)
throws an exception, the caller must handle it by closing call
with an error. Since call
can only be closed once, an implementation can report errors
either to ServerCall.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 with call
to be delivered there.
call
- object for responding to the remote client.headers
- request headers received from the client but open to modification by an ownercall