public class InProcessOrAlternativeChannelFactory extends Object implements GrpcChannelFactory
InProcessChannelFactory and an alternative implementation. All
channels that are configured with the in-process scheme will be handled by the in-process-channel-factory,
the other channels will be handled by the alternative implementation.
The following examples show how the configured address will be mapped to an actual channel:
in-process:foobar -> will use the foobar in-process-channel.in-process:foo/bar -> will use the foo/bar in-process-channel.static://127.0.0.1 -> will be handled by the alternative grpc channel factory.Using this class does not incur any additional performance or resource costs, as the actual channels (in-process or other) are only created on demand.
| Constructor and Description |
|---|
InProcessOrAlternativeChannelFactory(GrpcChannelsProperties properties,
InProcessChannelFactory inProcessChannelFactory,
GrpcChannelFactory alternativeChannelFactory)
Creates a new InProcessOrAlternativeChannelFactory with the given properties and channel factories.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
io.grpc.Channel |
createChannel(String name,
List<io.grpc.ClientInterceptor> interceptors,
boolean sortInterceptors)
Creates a new channel for the given service name.
|
Map<String,io.grpc.ConnectivityState> |
getConnectivityState()
Gets an unmodifiable map that contains the names of the created channel with their current
ConnectivityState. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcreateChannel, createChannelpublic InProcessOrAlternativeChannelFactory(GrpcChannelsProperties properties, InProcessChannelFactory inProcessChannelFactory, GrpcChannelFactory alternativeChannelFactory)
properties - The properties used to resolved the target schemeinProcessChannelFactory - The in process channel factory implementation to use.alternativeChannelFactory - The alternative channel factory implementation to use.public io.grpc.Channel createChannel(String name, List<io.grpc.ClientInterceptor> interceptors, boolean sortInterceptors)
GrpcChannelFactoryClientInterceptors.
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...).
createChannel in interface GrpcChannelFactoryname - 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.public Map<String,io.grpc.ConnectivityState> getConnectivityState()
GrpcChannelFactoryConnectivityState. This method will return an empty map, if the feature is not supported.getConnectivityState in interface GrpcChannelFactorypublic void close()
close in interface AutoCloseableclose in interface GrpcChannelFactory