• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2014 The gRPC Authors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package io.grpc;
18 
19 import javax.annotation.concurrent.ThreadSafe;
20 
21 /**
22  * Interface to initiate processing of incoming remote calls. Advanced applications and generated
23  * code will implement this interface to allows {@link Server}s to invoke service methods.
24  */
25 @ThreadSafe
26 public interface ServerCallHandler<RequestT, ResponseT> {
27   /**
28    * Produce a non-{@code null} listener for the incoming call. Implementations are free to call
29    * methods on {@code call} before this method has returned.
30    *
31    * <p>Since {@link Metadata} is not thread-safe, the caller must not access (read or write) {@code
32    * headers} after this point.
33    *
34    * <p>If the implementation throws an exception, {@code call} will be closed with an error.
35    * Implementations must not throw an exception if they started processing that may use {@code
36    * call} on another thread.
37    *
38    * @param call object for responding to the remote client.
39    * @return listener for processing incoming request messages for {@code call}
40    */
startCall( ServerCall<RequestT, ResponseT> call, Metadata headers)41   ServerCall.Listener<RequestT> startCall(
42       ServerCall<RequestT, ResponseT> call,
43       Metadata headers);
44 }
45