public static final class ConnectionPoolConfiguration.Builder extends Object
ConnectionPoolConfiguration instances.
This class is not threadsafe
| Modifier and Type | Method and Description |
|---|---|
ConnectionPoolConfiguration.Builder |
acquireRetry(int retryAttempts)
Configure the number of acquire retries if the first acquiry attempt fails.
|
ConnectionPoolConfiguration.Builder |
allocatorSubscribeOn(Scheduler scheduler)
Configure
Scheduler to use for allocation. |
ConnectionPoolConfiguration.Builder |
backgroundEvictionInterval(Duration backgroundEvictionInterval)
Configure the background eviction
interval to evict idle connections while the pool isn't actively used for allocations/releases. |
ConnectionPoolConfiguration |
build()
Returns a configured
ConnectionPoolConfiguration. |
ConnectionPoolConfiguration.Builder |
clock(Clock clock)
Configure the
Clock used for allocation and eviction timing. |
ConnectionPoolConfiguration.Builder |
connectionFactory(ConnectionFactory connectionFactory)
Configure connection factory.
|
ConnectionPoolConfiguration.Builder |
customizer(Consumer<reactor.pool.PoolBuilder<Connection,? extends reactor.pool.PoolConfig<? extends Connection>>> customizer)
Configure a customizer for
PoolBuilder that constructs the Connection pool. |
ConnectionPoolConfiguration.Builder |
initialSize(int initialSize)
Configure the initial connection pool size.
|
ConnectionPoolConfiguration.Builder |
maxAcquireTime(Duration maxAcquireTime)
Configure
timeout for acquiring a Connection from pool. |
ConnectionPoolConfiguration.Builder |
maxCreateConnectionTime(Duration maxCreateConnectionTime)
|
ConnectionPoolConfiguration.Builder |
maxIdleTime(Duration maxIdleTime)
Configure a idle
timeout. |
ConnectionPoolConfiguration.Builder |
maxLifeTime(Duration maxLifeTime)
Configure
lifetime of the pooled Connection in the pool. |
ConnectionPoolConfiguration.Builder |
maxSize(int maxSize)
Configure the maximal connection pool size.
|
ConnectionPoolConfiguration.Builder |
maxValidationTime(Duration maxValidationTime)
Configure
timeout for validating a Connection from pool. |
ConnectionPoolConfiguration.Builder |
metricsRecorder(reactor.pool.PoolMetricsRecorder recorder)
Configure
PoolMetricsRecorder to calculate elapsed time and instrumentation data |
ConnectionPoolConfiguration.Builder |
minIdle(int minIdle)
Configure the minimal number of idle connections.
|
ConnectionPoolConfiguration.Builder |
name(String name)
Configure the name of the connection pool.
|
ConnectionPoolConfiguration.Builder |
postAllocate(Function<? super Connection,? extends Publisher<Void>> postAllocate)
Configure a
Lifecycle.postAllocate() callback function. |
ConnectionPoolConfiguration.Builder |
preRelease(Function<? super Connection,? extends Publisher<Void>> preRelease)
Configure a
Lifecycle.preRelease() callback function. |
ConnectionPoolConfiguration.Builder |
registerJmx(boolean registerJmx)
Configure whether to register to JMX.
|
String |
toString() |
ConnectionPoolConfiguration.Builder |
validationDepth(ValidationDepth validationDepth)
Configure validation depth for
connection validation. |
ConnectionPoolConfiguration.Builder |
validationQuery(String validationQuery)
Configure a validation query.
|
public ConnectionPoolConfiguration.Builder allocatorSubscribeOn(Scheduler scheduler)
Scheduler to use for allocation. Defaults to Schedulers.single().
Configuring the scheduler can be relevant to coordinate thread co-location.scheduler - the scheduler to use.ConnectionPoolConfiguration.BuilderIllegalArgumentException - if scheduler is null.Schedulers.single()public ConnectionPoolConfiguration.Builder acquireRetry(int retryAttempts)
retryAttempts - the number of retries. Can be zero or any positive numberConnectionPoolConfiguration.BuilderIllegalArgumentException - if retryAttempts is less than zero.Mono.retry(long)public ConnectionPoolConfiguration.Builder backgroundEvictionInterval(@Nullable Duration backgroundEvictionInterval)
interval to evict idle connections while the pool isn't actively used for allocations/releases.backgroundEvictionInterval - background eviction interval. Duration.ZERO, a negative or a null value results in disabling background eviction.ConnectionPoolConfiguration.Builderpublic ConnectionPoolConfiguration.Builder clock(Clock clock)
Clock used for allocation and eviction timing.clock - the Clock to use.ConnectionPoolConfiguration.BuilderIllegalArgumentException - if clock is null.public ConnectionPoolConfiguration.Builder customizer(Consumer<reactor.pool.PoolBuilder<Connection,? extends reactor.pool.PoolConfig<? extends Connection>>> customizer)
PoolBuilder that constructs the Connection pool.customizer - customizer for PoolBuilder that creates the Connection pool, must not be null.ConnectionPoolConfiguration.BuilderIllegalArgumentException - if customizer is nullpublic ConnectionPoolConfiguration.Builder initialSize(int initialSize)
10.initialSize - the initial pool size, must be equal or greater than zero.ConnectionPoolConfiguration.BuilderIllegalArgumentException - if maxSize is negative or zero.public ConnectionPoolConfiguration.Builder minIdle(int minIdle)
0.minIdle - the minimal amount of idle connections in the pool, must not be negative.ConnectionPoolConfiguration.BuilderIllegalArgumentException - if minIdle is negative.public ConnectionPoolConfiguration.Builder maxSize(int maxSize)
10.maxSize - the maximal pool size, must be greater than zero.ConnectionPoolConfiguration.BuilderIllegalArgumentException - if maxSize is negative or zero.public ConnectionPoolConfiguration.Builder maxAcquireTime(@Nullable Duration maxAcquireTime)
timeout for acquiring a Connection from pool. Default is no timeout.
When acquiring a Connection requires obtaining a new Connection from underlying ConnectionFactory, this timeout
also applies to get the new one.
maxAcquireTime - the maximum time to acquire connection from pool. Duration.ZERO indicates that the connection must be immediately available
otherwise acquisition fails. A negative or a null value results in not applying a timeout.ConnectionPoolConfiguration.Builderpublic ConnectionPoolConfiguration.Builder maxCreateConnectionTime(@Nullable Duration maxCreateConnectionTime)
maxCreateConnectionTime - the maximum time to create a new Connection from ConnectionFactory.
Duration.ZERO indicates immediate failure if the connection is not created immediately. A negative or a null value results in not applying
a timeout.ConnectionPoolConfiguration.Builderpublic ConnectionPoolConfiguration.Builder maxIdleTime(@Nullable Duration maxIdleTime)
timeout. Defaults to 30 minutes. Configuring maxIdleTime enables background eviction using the configured idle time as interval unless
backgroundEvictionInterval(Duration) is configured.maxIdleTime - the maximum idle time. Duration.ZERO means immediate connection disposal. A negative or a null value results in not applying a timeout.ConnectionPoolConfiguration.Builderpublic ConnectionPoolConfiguration.Builder maxLifeTime(Duration maxLifeTime)
lifetime of the pooled Connection in the pool. Default is no timeout.maxLifeTime - the maximum lifetime of the connection in the pool,.
Duration.ZERO indicates immediate connection disposal. A negative or a null value results in not applying a timeout.ConnectionPoolConfiguration.Builderpublic ConnectionPoolConfiguration.Builder maxValidationTime(Duration maxValidationTime)
timeout for validating a Connection from pool. Default is no timeout.maxValidationTime - the maximum time to validate connection from pool. Duration.ZERO indicates that the connection must be immediately validated
otherwise validation fails. A negative or a null value results in not applying a timeout.ConnectionPoolConfiguration.BuilderConnection.validate(ValidationDepth),
validationQuery(String),
validationDepth(ValidationDepth)public ConnectionPoolConfiguration.Builder metricsRecorder(reactor.pool.PoolMetricsRecorder recorder)
PoolMetricsRecorder to calculate elapsed time and instrumentation datarecorder - the PoolMetricsRecorderConnectionPoolConfiguration.BuilderIllegalArgumentException - if recorder is nullpublic ConnectionPoolConfiguration.Builder name(String name)
name - pool nameConnectionPoolConfiguration.BuilderIllegalArgumentException - if name is nullpublic ConnectionPoolConfiguration.Builder postAllocate(Function<? super Connection,? extends Publisher<Void>> postAllocate)
Lifecycle.postAllocate() callback function. This Function is called with a Connection object that was allocated from the pool before emitting it
through ConnectionFactory.create().
The connection emission is delayed until the returned Publisher has completed. Any error signals from this publisher lead to immediate disposal of the connection.
If a Connection implements Lifecycle, the given function is called once Lifecycle.postAllocate() has completed.postAllocate - function applied to Connection returning a publisher to perform actions before returning the connection to the callerConnectionPoolConfiguration.BuilderIllegalArgumentException - if postAllocate is nullpublic ConnectionPoolConfiguration.Builder preRelease(Function<? super Connection,? extends Publisher<Void>> preRelease)
Lifecycle.preRelease() callback function. This Function is called with a Connection object that is about to be returned to the pool right before
releasing it.
through Connection.close().
The connection release is delayed until the returned Publisher has completed. Any error signals from this publisher lead to immediate disposal of the connection instead of
returning it to the pool.
If a Connection implements Lifecycle, the given function is called before invoking Lifecycle.preRelease().preRelease - function applied to Connection returning a publisher to perform actions before releasing the connectionConnectionPoolConfiguration.BuilderIllegalArgumentException - if preRelease is nullpublic ConnectionPoolConfiguration.Builder registerJmx(boolean registerJmx)
false.registerJmx - register the pool to JMXConnectionPoolConfiguration.Builderpublic ConnectionPoolConfiguration.Builder validationDepth(ValidationDepth validationDepth)
connection validation.validationDepth - the depth of validation, must not be nullConnectionPoolConfiguration.BuilderIllegalArgumentException - if validationDepth is nullpublic ConnectionPoolConfiguration.Builder connectionFactory(ConnectionFactory connectionFactory)
connectionFactory - the connection factory to connect to the db, must not be nullConnectionPoolConfiguration.BuilderIllegalArgumentException - if connectionFactory is nullpublic ConnectionPoolConfiguration.Builder validationQuery(String validationQuery)
Connection.validate(ValidationDepth) is not used.validationQuery - the validation query to run before returning a Connection from the pool, must not be null.ConnectionPoolConfiguration.BuilderIllegalArgumentException - if validationQuery is nullpublic ConnectionPoolConfiguration build()
ConnectionPoolConfiguration.ConnectionPoolConfigurationIllegalArgumentException - if registerJmx is true AND name is nullCopyright © 2023. All rights reserved.