1 /*
2  * Copyright 2015 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.internal;
18 
19 import io.grpc.InternalChannelz.SocketStats;
20 import io.grpc.InternalInstrumented;
21 import io.grpc.Status;
22 import java.util.concurrent.ScheduledExecutorService;
23 
24 /** An inbound connection. */
25 public interface ServerTransport extends InternalInstrumented<SocketStats> {
26   /**
27    * Initiates an orderly shutdown of the transport. Existing streams continue, but new streams will
28    * eventually begin failing. New streams "eventually" begin failing because shutdown may need to
29    * be processed on a separate thread. May only be called once.
30    */
shutdown()31   void shutdown();
32 
33   /**
34    * Initiates a forceful shutdown in which preexisting and new calls are closed. Existing calls
35    * should be closed with the provided {@code reason}.
36    */
shutdownNow(Status reason)37   void shutdownNow(Status reason);
38 
39   /**
40    * Returns an executor for scheduling provided by the transport. The service should be configured
41    * to allow cancelled scheduled runnables to be GCed.
42    *
43    * <p>The executor may not be used after the transport terminates. The caller should ensure any
44    * outstanding tasks are cancelled when the transport terminates.
45    */
getScheduledExecutorService()46   ScheduledExecutorService getScheduledExecutorService();
47 }
48