@ThreadSafe public class GrpcManagedChannelPool extends Object
ManagedChannel
instances per process.
This class is used internally by GrpcChannelBuilder
and GrpcChannel
.Modifier and Type | Class and Description |
---|---|
static class |
GrpcManagedChannelPool.ChannelKey
Used to identify a unique
ManagedChannel in the pool. |
static class |
GrpcManagedChannelPool.PoolingStrategy
Enumeration to determine the pooling strategy.
|
Modifier and Type | Field and Description |
---|---|
protected ScheduledExecutorService |
mScheduler
Scheduler for destruction of idle channels.
|
Constructor and Description |
---|
GrpcManagedChannelPool()
Creates a new
GrpcManagedChannelPool . |
Modifier and Type | Method and Description |
---|---|
io.grpc.ManagedChannel |
acquireManagedChannel(GrpcManagedChannelPool.ChannelKey channelKey,
long healthCheckTimeoutMs,
long shutdownTimeoutMs)
Acquires and increases the ref-count for the
ManagedChannel . |
static GrpcManagedChannelPool |
INSTANCE() |
void |
releaseManagedChannel(GrpcManagedChannelPool.ChannelKey channelKey,
long shutdownTimeoutMs)
Decreases the ref-count of the
ManagedChannel for the given address. |
protected ScheduledExecutorService mScheduler
public GrpcManagedChannelPool()
GrpcManagedChannelPool
.public static GrpcManagedChannelPool INSTANCE()
public io.grpc.ManagedChannel acquireManagedChannel(GrpcManagedChannelPool.ChannelKey channelKey, long healthCheckTimeoutMs, long shutdownTimeoutMs)
ManagedChannel
.channelKey
- channel keyhealthCheckTimeoutMs
- health check timeout in millisecondsshutdownTimeoutMs
- shutdown timeout in millisecondsManagedChannel
public void releaseManagedChannel(GrpcManagedChannelPool.ChannelKey channelKey, long shutdownTimeoutMs)
ManagedChannel
for the given address.
It shuts down and releases the ManagedChannel
if reference count reaches zero.channelKey
- host addressshutdownTimeoutMs
- shutdown timeout in millisecondsCopyright © 2023. All Rights Reserved.