Package reactor.netty.resources
Class ConnectionProvider.Builder
java.lang.Object
reactor.netty.resources.ConnectionProvider.ConnectionPoolSpec<ConnectionProvider.Builder>
reactor.netty.resources.ConnectionProvider.Builder
- All Implemented Interfaces:
Supplier<ConnectionProvider.Builder>
- Enclosing interface:
- ConnectionProvider
public static final class ConnectionProvider.Builder
extends ConnectionProvider.ConnectionPoolSpec<ConnectionProvider.Builder>
Build a
ConnectionProvider
to cache and reuse a fixed maximum number of
Connection
. Further connections will be pending acquisition depending on
pendingAcquireTime. The maximum number of connections is for the connections in a single
connection pool, where a connection pool corresponds to a concrete remote host.
The configuration can be either global for all connection pools or
be tuned for each individual connection pool, per remote host.- Since:
- 0.9.5
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Builds new ConnectionProvider.disposeInactivePoolsInBackground
(Duration disposeInterval, Duration poolInactivity) Set the options to use for configuringConnectionProvider
background disposal for inactive connection pools.disposeTimeout
(Duration timeout) WhenConnectionProvider.dispose()
orConnectionProvider.disposeLater()
is called, trigger agraceful shutdown
for the connection pools, with this grace period timeout.forRemoteHost
(SocketAddress remoteHost, Consumer<ConnectionProvider.HostSpecificSpec> spec) Connection pool configuration for a specific remote host.maxConnectionPools
(int maxConnectionPools) Specifies the maximum number of connection pools that the provider can create.ConnectionProvider
name is used for metrics.Methods inherited from class reactor.netty.resources.ConnectionProvider.ConnectionPoolSpec
allocationStrategy, evictInBackground, evictionPredicate, fifo, get, lifo, maxConnections, maxIdleTime, maxLifeTime, metrics, metrics, pendingAcquireMaxCount, pendingAcquireTimeout, pendingAcquireTimer
-
Method Details
-
name
ConnectionProvider
name is used for metrics.- Parameters:
name
-ConnectionProvider
name- Returns:
- this
- Throws:
NullPointerException
- if name is null
-
disposeInactivePoolsInBackground
public final ConnectionProvider.Builder disposeInactivePoolsInBackground(Duration disposeInterval, Duration poolInactivity) Set the options to use for configuringConnectionProvider
background disposal for inactive connection pools. When this option is enabled, the connection pools are regularly checked whether they are empty and inactive for a specified time, thus applicable for disposal. Connection pool is considered empty when there are no active connections, idle connections and pending acquisitions. Default toDISPOSE_INACTIVE_POOLS_IN_BACKGROUND_DISABLED
- the background disposal is disabled. Providing adisposeInterval
ofzero
means the background disposal is disabled.- Parameters:
disposeInterval
- specifies the interval to be used for checking the connection pool inactivity, (resolution: ms)poolInactivity
- specifies the duration after which an empty pool with no recorded interactions is considered inactive (resolution: seconds)- Returns:
- this
- Since:
- 1.0.7
-
disposeTimeout
WhenConnectionProvider.dispose()
orConnectionProvider.disposeLater()
is called, trigger agraceful shutdown
for the connection pools, with this grace period timeout. From there on, all calls for acquiring a connection will fail fast with an exception. However, for the providedDuration
, pending acquires will get a chance to be served.Note: The rejection of new acquires and the grace timer start immediately, irrespective of subscription to the
Mono
returned byConnectionProvider.disposeLater()
. Subsequent calls return the sameMono
, effectively getting notifications from the first graceful shutdown call and ignoring subsequently provided timeouts.- Parameters:
timeout
- the maximumDuration
for graceful shutdown before full shutdown is forced (resolution: ms)- Returns:
- this
- Since:
- 1.0.12
-
forRemoteHost
public final ConnectionProvider.Builder forRemoteHost(SocketAddress remoteHost, Consumer<ConnectionProvider.HostSpecificSpec> spec) Connection pool configuration for a specific remote host.- Parameters:
remoteHost
- the remote hostspec
- connection pool configuration for this remote host- Returns:
- this
- Throws:
NullPointerException
- if remoteHost or/and spec are null
-
maxConnectionPools
Specifies the maximum number of connection pools that the provider can create. If the number of connection pools created exceeds this value, a warning message is logged. The value must be strictly positive or -1; otherwise, the connection pools check is ignored. Setting the configuration to -1 disables the setting.- Parameters:
maxConnectionPools
- the maximum number of connection pools that can be created- Returns:
- the current
ConnectionProvider.Builder
instance with the updated configuration - Since:
- 1.2.2
-
build
Builds new ConnectionProvider.- Returns:
- builds new ConnectionProvider
-