@FunctionalInterface public interface ConnectionProvider extends Disposable
ConnectionProvider
will produce Connection
Modifier and Type | Interface and Description |
---|---|
static class |
ConnectionProvider.Builder
Build a
ConnectionProvider to cache and reuse a fixed maximum number of
Connection . |
static class |
ConnectionProvider.ConnectionPoolSpec<SPEC extends ConnectionProvider.ConnectionPoolSpec<SPEC>>
Configuration for a connection pool.
|
static class |
ConnectionProvider.HostSpecificSpec
Configuration for a connection pool per remote host.
|
static interface |
ConnectionProvider.MeterRegistrar
A strategy to register which metrics are collected in a particular connection pool.
|
Disposable.Composite, Disposable.Swap
Modifier and Type | Field and Description |
---|---|
static long |
DEFAULT_POOL_ACQUIRE_TIMEOUT
Default acquisition timeout (milliseconds) before error.
|
static String |
DEFAULT_POOL_LEASING_STRATEGY
Default leasing strategy (fifo, lifo), fallback to fifo.
|
static int |
DEFAULT_POOL_MAX_CONNECTIONS
Default max connections.
|
static long |
DEFAULT_POOL_MAX_IDLE_TIME
Default max idle time, fallback - max idle time is not specified.
|
static long |
DEFAULT_POOL_MAX_LIFE_TIME
Default max life time, fallback - max life time is not specified.
|
static String |
LEASING_STRATEGY_FIFO
The connection selection is first in, first out.
|
static String |
LEASING_STRATEGY_LIFO
The connection selection is last in, first out.
|
Modifier and Type | Method and Description |
---|---|
Mono<? extends Connection> |
acquire(Bootstrap bootstrap)
Return an existing or new
Connection on subscribe. |
static ConnectionProvider.Builder |
builder(String name)
Creates a builder for
ConnectionProvider |
static ConnectionProvider |
create(String name)
Create a new
ConnectionProvider to cache and reuse a fixed maximum
number of Connection . |
static ConnectionProvider |
create(String name,
int maxConnections)
Create a new
ConnectionProvider to cache and reuse a fixed maximum
number of Connection . |
default void |
dispose()
Dispose this ConnectionProvider.
|
default Mono<Void> |
disposeLater()
Returns a Mono that triggers the disposal of the ConnectionProvider when subscribed to.
|
default void |
disposeWhen(SocketAddress address) |
static ConnectionProvider |
elastic(String name)
Deprecated.
as of 0.9.5. Use
builder(String) |
static ConnectionProvider |
elastic(String name,
java.time.Duration maxIdleTime)
Deprecated.
as of 0.9.5. Use
builder(String) |
static ConnectionProvider |
elastic(String name,
java.time.Duration maxIdleTime,
java.time.Duration maxLifeTime)
Deprecated.
as of 0.9.5. Use
builder(String) |
static ConnectionProvider |
fixed(String name)
Deprecated.
as of 0.9.5. Use
create(String) |
static ConnectionProvider |
fixed(String name,
int maxConnections)
Deprecated.
as of 0.9.5. Use
create(String, int) |
static ConnectionProvider |
fixed(String name,
int maxConnections,
long acquireTimeout)
Deprecated.
as of 0.9.5. Use
builder(String) |
static ConnectionProvider |
fixed(String name,
int maxConnections,
long acquireTimeout,
java.time.Duration maxIdleTime)
Deprecated.
as of 0.9.5. Use
builder(String) |
static ConnectionProvider |
fixed(String name,
int maxConnections,
long acquireTimeout,
java.time.Duration maxIdleTime,
java.time.Duration maxLifeTime)
Deprecated.
as of 0.9.5. Use
builder(String) |
default int |
maxConnections()
Returns the maximum number of connections before starting pending
|
static ConnectionProvider |
newConnection()
Return a
ConnectionProvider that will always create a new
Connection . |
isDisposed
static final int DEFAULT_POOL_MAX_CONNECTIONS
static final long DEFAULT_POOL_ACQUIRE_TIMEOUT
static final long DEFAULT_POOL_MAX_IDLE_TIME
static final long DEFAULT_POOL_MAX_LIFE_TIME
static final String LEASING_STRATEGY_FIFO
static final String LEASING_STRATEGY_LIFO
static final String DEFAULT_POOL_LEASING_STRATEGY
static ConnectionProvider.Builder builder(String name)
ConnectionProvider
name
- ConnectionProvider
namestatic ConnectionProvider newConnection()
ConnectionProvider
that will always create a new
Connection
.ConnectionProvider
that will always create a new
Connection
.static ConnectionProvider create(String name)
ConnectionProvider
to cache and reuse a fixed maximum
number of Connection
.
A Fixed ConnectionProvider
will open up to the given max number of
processors observed by this jvm (minimum 4).
Further connections will be pending acquisition until DEFAULT_POOL_ACQUIRE_TIMEOUT
and the default pending acquisition max count will be 500.
name
- the connection pool nameConnectionProvider
to cache and reuse a fixed maximum
number of Connection
static ConnectionProvider create(String name, int maxConnections)
ConnectionProvider
to cache and reuse a fixed maximum
number of Connection
.
A Fixed ConnectionProvider
will open up to the given max connection value.
Further connections will be pending acquisition until DEFAULT_POOL_ACQUIRE_TIMEOUT
and the default pending acquisition max count will be 2 * max connections value.
name
- the connection pool namemaxConnections
- the maximum number of connections before starting pending
acquisition on existing onesConnectionProvider
to cache and reuse a fixed maximum
number of Connection
@Deprecated static ConnectionProvider elastic(String name)
builder(String)
ConnectionProvider
to cache and grow on demand Connection
.
An elastic ConnectionProvider
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 nameConnectionProvider
to cache and grow on demand Connection
@Deprecated static ConnectionProvider elastic(String name, @Nullable java.time.Duration maxIdleTime)
builder(String)
ConnectionProvider
to cache and grow on demand Connection
.
An elastic ConnectionProvider
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 namemaxIdleTime
- the Duration
after which the channel will be closed when idle (resolution: ms),
if NULL
there is no max idle timeConnectionProvider
to cache and grow on demand Connection
@Deprecated static ConnectionProvider elastic(String name, @Nullable java.time.Duration maxIdleTime, @Nullable java.time.Duration maxLifeTime)
builder(String)
ConnectionProvider
to cache and grow on demand Connection
.
An elastic ConnectionProvider
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 namemaxIdleTime
- the Duration
after which the channel will be closed when idle (resolution: ms),
if NULL
there is no max idle timemaxLifeTime
- the Duration
after which the channel will be closed (resolution: ms),
if NULL
there is no max life timeConnectionProvider
to cache and grow on demand Connection
@Deprecated static ConnectionProvider fixed(String name)
create(String)
ConnectionProvider
to cache and reuse a fixed maximum
number of Connection
.
A Fixed ConnectionProvider
will open up to the given max number of
processors observed by this jvm (minimum 4).
Further connections will be pending acquisition until DEFAULT_POOL_ACQUIRE_TIMEOUT
and the default pending acquisition max count will be unbounded.
name
- the connection pool nameConnectionProvider
to cache and reuse a fixed maximum
number of Connection
@Deprecated static ConnectionProvider fixed(String name, int maxConnections)
create(String, int)
ConnectionProvider
to cache and reuse a fixed maximum
number of Connection
.
A Fixed ConnectionProvider
will open up to the given max connection value.
Further connections will be pending acquisition until DEFAULT_POOL_ACQUIRE_TIMEOUT
and the default pending acquisition max count will be unbounded.
name
- the connection pool namemaxConnections
- the maximum number of connections before starting pending
acquisition on existing onesConnectionProvider
to cache and reuse a fixed maximum
number of Connection
@Deprecated static ConnectionProvider fixed(String name, int maxConnections, long acquireTimeout)
builder(String)
ConnectionProvider
to cache and reuse a fixed maximum
number of Connection
.
A Fixed ConnectionProvider
will open up to the given max connection value.
Further connections will be pending acquisition until acquireTimeout
and the default pending acquisition max count will be unbounded.
name
- the connection pool namemaxConnections
- the maximum number of connections before starting pendingacquireTimeout
- the maximum time in millis after which a pending acquire
must complete or the TimeoutException
will be thrown.ConnectionProvider
to cache and reuse a fixed maximum
number of Connection
@Deprecated static ConnectionProvider fixed(String name, int maxConnections, long acquireTimeout, @Nullable java.time.Duration maxIdleTime)
builder(String)
ConnectionProvider
to cache and reuse a fixed maximum
number of Connection
.
A Fixed ConnectionProvider
will open up to the given max connection value.
Further connections will be pending acquisition until acquireTimeout
and the default pending acquisition max count will be unbounded.
name
- the connection pool namemaxConnections
- the maximum number of connections before starting pendingacquireTimeout
- the maximum time in millis after which a pending acquire
must complete or the TimeoutException
will be thrown.maxIdleTime
- the Duration
after which the channel will be closed when idle (resolution: ms),
if NULL
there is no max idle timeConnectionProvider
to cache and reuse a fixed maximum
number of Connection
@Deprecated static ConnectionProvider fixed(String name, int maxConnections, long acquireTimeout, @Nullable java.time.Duration maxIdleTime, @Nullable java.time.Duration maxLifeTime)
builder(String)
ConnectionProvider
to cache and reuse a fixed maximum
number of Connection
.
A Fixed ConnectionProvider
will open up to the given max connection value.
Further connections will be pending acquisition until acquireTimeout
and the default pending acquisition max count will be unbounded.
name
- the connection pool namemaxConnections
- the maximum number of connections before starting pendingacquireTimeout
- the maximum time in millis after which a pending acquire
must complete or the TimeoutException
will be thrown.maxIdleTime
- the Duration
after which the channel will be closed when idle (resolution: ms),
if NULL
there is no max idle timemaxLifeTime
- the Duration
after which the channel will be closed (resolution: ms),
if NULL
there is no max life timeConnectionProvider
to cache and reuse a fixed maximum
number of Connection
Mono<? extends Connection> acquire(Bootstrap bootstrap)
Connection
on subscribe.bootstrap
- the client connection Bootstrap
Mono
of Connection
default void disposeWhen(@NonNull SocketAddress address)
default void dispose()
disposeLater()
when you need to observe the final
status of the operation, combined with Mono.block()
if you need to synchronously wait for the underlying resources to be disposed.dispose
in interface Disposable
default Mono<Void> disposeLater()
default int maxConnections()