• 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  * A virtual connection to a conceptual endpoint, to perform RPCs. A channel is free to have zero or
23  * many actual connections to the endpoint based on configuration, load, etc. A channel is also free
24  * to determine which actual endpoints to use and may change it every RPC, permitting client-side
25  * load balancing. Applications are generally expected to use stubs instead of calling this class
26  * directly.
27  *
28  * <p>Applications can add common cross-cutting behaviors to stubs by decorating Channel
29  * implementations using {@link ClientInterceptor}. It is expected that most application
30  * code will not use this class directly but rather work with stubs that have been bound to a
31  * Channel that was decorated during application initialization.
32  */
33 @ThreadSafe
34 public abstract class Channel {
35   /**
36    * Create a {@link ClientCall} to the remote operation specified by the given
37    * {@link MethodDescriptor}. The returned {@link ClientCall} does not trigger any remote
38    * behavior until {@link ClientCall#start(ClientCall.Listener, Metadata)} is
39    * invoked.
40    *
41    * @param methodDescriptor describes the name and parameter types of the operation to call.
42    * @param callOptions runtime options to be applied to this call.
43    * @return a {@link ClientCall} bound to the specified method.
44    * @since 1.0.0
45    */
newCall( MethodDescriptor<RequestT, ResponseT> methodDescriptor, CallOptions callOptions)46   public abstract <RequestT, ResponseT> ClientCall<RequestT, ResponseT> newCall(
47       MethodDescriptor<RequestT, ResponseT> methodDescriptor, CallOptions callOptions);
48 
49   /**
50    * The authority of the destination this channel connects to. Typically this is in the format
51    * {@code host:port}.
52    *
53    * @since 1.0.0
54    */
authority()55   public abstract String authority();
56 }
57