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 allowsServers 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
ServerCallandMetadataarguments to theServerCallHandlerimplementation for processing. Ownership means that the implementation may invoke methods oncallandheaderswhilestartCall(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 ofcallandheadersreverts 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 closingcallwith an error. Sincecallcan 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-
nulllistener for the incoming call. Callers of this method must arrange for events associated withcallto 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
-
-