Interface GrpcChannelFactory
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
AbstractChannelFactory,InProcessChannelFactory,InProcessOrAlternativeChannelFactory,NettyChannelFactory,ShadedNettyChannelFactory
This factory creates grpc
Channels 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 TypeMethodDescriptionvoidclose()default ChannelcreateChannel(String name) Creates a new channel for the given service name.default ChannelcreateChannel(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 registeredClientInterceptors.Note: The underlying implementation might reuse existing
ManagedChannels 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 registeredClientInterceptors.Note: The underlying implementation might reuse existing
ManagedChannels 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 registeredClientInterceptors.Note: The underlying implementation might reuse existing
ManagedChannels 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:
closein interfaceAutoCloseable
-