Interface GrpcChannelFactory
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
AbstractChannelFactory
,InProcessChannelFactory
,InProcessOrAlternativeChannelFactory
,NettyChannelFactory
,ShadedNettyChannelFactory
This factory creates grpc
Channel
s for a given service name. Implementations are encouraged to utilize
connection pooling and thus close
should be called before disposing it.- Since:
- 5/17/16
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
default Channel
createChannel
(String name) Creates a new channel for the given service name.default Channel
createChannel
(String name, List<ClientInterceptor> interceptors) Creates a new channel for the given service name.createChannel
(String name, List<ClientInterceptor> interceptors, boolean sortInterceptors) Creates a new channel for the given service name.default Map<String,
ConnectivityState> Gets an unmodifiable map that contains the names of the created channel with their currentConnectivityState
.
-
Method Details
-
createChannel
Creates a new channel for the given service name. The returned channel will use all globally registeredClientInterceptor
s.Note: The underlying implementation might reuse existing
ManagedChannel
s allow connection reuse.- Parameters:
name
- The name of the service.- Returns:
- The newly created channel for the given service.
-
createChannel
Creates a new channel for the given service name. The returned channel will use all globally registeredClientInterceptor
s.Note: The underlying implementation might reuse existing
ManagedChannel
s allow connection reuse.Note: The given interceptors will be appended to the global interceptors and applied using
ClientInterceptors.interceptForward(Channel, ClientInterceptor...)
.- Parameters:
name
- The name of the service.interceptors
- A list of additional client interceptors that should be added to the channel.- Returns:
- The newly created channel for the given service.
-
createChannel
Creates a new channel for the given service name. The returned channel will use all globally registeredClientInterceptor
s.Note: The underlying implementation might reuse existing
ManagedChannel
s allow connection reuse.Note: The given interceptors will be appended to the global interceptors and applied using
ClientInterceptors.interceptForward(Channel, ClientInterceptor...)
.- Parameters:
name
- The name of the service.interceptors
- A list of additional client interceptors that should be added to the channel.sortInterceptors
- Whether the interceptors (both global and custom) should be sorted before being applied.- Returns:
- The newly created channel for the given service.
-
getConnectivityState
Gets an unmodifiable map that contains the names of the created channel with their currentConnectivityState
. This method will return an empty map, if the feature is not supported.- Returns:
- A map with the channel names and their connectivity state.
-
close
void close()- Specified by:
close
in interfaceAutoCloseable
-