@FunctionalInterface public interface ConnectionProvider extends Disposable
ConnectionProvider
will produce Connection
Disposable.Composite, Disposable.Swap
Modifier and Type | Field and Description |
---|---|
static long |
DEFAULT_POOL_ACQUIRE_TIMEOUT
Default acquisition timeout (milliseconds) before error.
|
static int |
DEFAULT_POOL_MAX_CONNECTIONS
Default max connections.
|
Modifier and Type | Method and Description |
---|---|
Mono<? extends Connection> |
acquire(Bootstrap bootstrap)
Return an existing or new
Connection on subscribe. |
default void |
dispose() |
default Mono<Void> |
disposeLater()
Returns a Mono that triggers the disposal of underlying resources when subscribed to.
|
default void |
disposeWhen(SocketAddress address) |
static ConnectionProvider |
elastic(String name)
Create a
ConnectionProvider to cache and grow on demand Connection . |
static ConnectionProvider |
fixed(String name)
a new
ConnectionProvider to cache and reuse a fixed maximum
number of Connection . |
static ConnectionProvider |
fixed(String name,
int maxConnections)
Create a new
ConnectionProvider to cache and reuse a fixed maximum
number of Connection . |
static ConnectionProvider |
fixed(String name,
int maxConnections,
long acquireTimeout)
Create a new
ConnectionProvider to cache and reuse a fixed maximum
number of Connection . |
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 ConnectionProvider newConnection()
ConnectionProvider
that will always create a new
Connection
.ConnectionProvider
that will always create a new
Connection
.static ConnectionProvider elastic(String name)
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
static ConnectionProvider fixed(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 indefinitely.
name
- the connection pool nameConnectionProvider
to cache and reuse a fixed maximum
number of Connection
static ConnectionProvider fixed(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 indefinitely.
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
static ConnectionProvider fixed(String name, int maxConnections, long acquireTimeout)
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 indefinitely.
name
- the connection pool namemaxConnections
- the maximum number of connections before starting pendingacquireTimeout
- the maximum time in millis to wait for acquiringConnectionProvider
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()
dispose
in interface Disposable
default Mono<Void> disposeLater()
default int maxConnections()