@FunctionalInterface public interface PoolResources extends Disposable
ChannelPool
selector with associated factories.Modifier and Type | Field and Description |
---|---|
static long |
DEFAULT_POOL_ACQUIRE_TIMEOUT
Default acquisition timeout before error.
|
static int |
DEFAULT_POOL_MAX_CONNECTION
Default max connection, if -1 will never wait to acquire before opening new
connection in an unbounded fashion.
|
Modifier and Type | Method and Description |
---|---|
default void |
dispose() |
static PoolResources |
elastic(String name)
Create an uncapped
PoolResources to provide automatically for ChannelPool . |
static PoolResources |
fixed(String name)
Create a capped
PoolResources to provide automatically for ChannelPool . |
static PoolResources |
fixed(String name,
int maxConnections)
Create a capped
PoolResources to provide automatically for ChannelPool . |
static PoolResources |
fixed(String name,
int maxConnections,
long acquireTimeout)
Create a capped
PoolResources to provide automatically for ChannelPool . |
ChannelPool |
selectOrCreate(SocketAddress address,
java.util.function.Supplier<? extends Bootstrap> bootstrap,
java.util.function.Consumer<? super Channel> onChannelCreate,
EventLoopGroup group)
Return an existing or new
ChannelPool . |
isDisposed
static final int DEFAULT_POOL_MAX_CONNECTION
static final long DEFAULT_POOL_ACQUIRE_TIMEOUT
static PoolResources elastic(String name)
PoolResources
to provide automatically for ChannelPool
.
An elastic PoolResources
will never wait before opening a new
connection. The reuse window is limited but it cannot starve an undetermined volume
of clients using it.
name
- the channel pool map namePoolResources
to provide automatically for ChannelPool
static PoolResources fixed(String name)
PoolResources
to provide automatically for ChannelPool
.
A Fixed PoolResources
will open up to the given max number of
processors observed by this jvm (minimum 4).
Further connections will be pending acquisition indefinitely.
name
- the channel pool map namePoolResources
to provide automatically for ChannelPool
static PoolResources fixed(String name, int maxConnections)
PoolResources
to provide automatically for ChannelPool
.
A Fixed PoolResources
will open up to the given max connection value.
Further connections will be pending acquisition indefinitely.
name
- the channel pool map namemaxConnections
- the maximum number of connections before starting pending
acquisition on existing onesPoolResources
to provide automatically for ChannelPool
static PoolResources fixed(String name, int maxConnections, long acquireTimeout)
PoolResources
to provide automatically for ChannelPool
.
A Fixed PoolResources
will open up to the given max connection value.
Further connections will be pending acquisition indefinitely.
name
- the channel pool map namemaxConnections
- the maximum number of connections before starting pendingacquireTimeout
- the maximum time in millis to wait for aquiringPoolResources
to provide automatically for ChannelPool
ChannelPool selectOrCreate(SocketAddress address, java.util.function.Supplier<? extends Bootstrap> bootstrap, java.util.function.Consumer<? super Channel> onChannelCreate, EventLoopGroup group)
ChannelPool
. The implementation will take care
of pulling Bootstrap
lazily when a ChannelPool
creation is actually
needed.address
- the remote address to resolve for existing or
new ChannelPool
bootstrap
- the Bootstrap
supplier if a ChannelPool
must be
createdonChannelCreate
- callback only when new connection is madeChannelPool
default void dispose()
dispose
in interface Cancellation
dispose
in interface Disposable