Top Description Fields Constructors Methods
reactor.pool

public Class PoolBuilder<T, CONF extends reactor.pool.PoolConfig<T>>

extends Object
Class Inheritance
Type Parameters
<T>
the type of elements in the produced Pool
<CONF>
the PoolConfig flavor this builder will provide to the created Pool
Imports
java.time.Clock, .Duration, java.util.Objects, java.util.concurrent.Callable, .TimeUnit, java.util.function.BiFunction, .BiPredicate, .Function, .Predicate, org.reactivestreams.Publisher, reactor.core.Disposable, reactor.core.publisher.Mono, reactor.core.scheduler.Scheduler, .Schedulers, reactor.util.retry.Retry

A builder for Pool implementations, which tuning methods map to a PoolConfig subclass, CONF.
Author
Simon Baslé

Field Summary

Modifier and TypeField and Description
pack-priv Scheduler
pack-priv AllocationStrategy
pack-priv final Mono<T>
pack-priv Clock
pack-priv final Function<PoolConfig<T>, CONF>
pack-priv static final BiFunction<Runnable, Duration, Disposable>
pack-priv static final int
pack-priv Function<T, ? extends Publisher<Void>>
pack-priv Duration
pack-priv Scheduler
pack-priv BiPredicate<T, PooledRefMetadata>
pack-priv boolean
pack-priv int
pack-priv PoolMetricsRecorder
pack-priv static final BiPredicate<?, ?>
pack-priv static final Function<?, Mono<Void>>
pack-priv BiFunction<Runnable, Duration, Disposable>
pack-priv Function<T, ? extends Publisher<Void>>

Constructor Summary

AccessConstructor and Description
pack-priv
PoolBuilder(Mono<T> allocator, Function<PoolConfig<T>, CONF> configModifier)

pack-priv
PoolBuilder(PoolBuilder<T, ?> source, Function<PoolConfig<T>, CONF> configModifier)

Method Summary

Modifier and TypeMethod and Description
public PoolBuilder<T, CONF>

Returns:

this Pool builder
acquisitionScheduler
(Scheduler
the Scheduler on which to deliver acquired resources
acquisitionScheduler
)

Provide a Scheduler that can optionally be used by a Pool to deliver its resources in a more deterministic (albeit potentially less efficient) way, thread-wise.

public PoolBuilder<T, CONF>

Returns:

this Pool builder
allocationStrategy
(AllocationStrategy allocationStrategy)

Limits in how many resources can be allocated and managed by the Pool are driven by the provided AllocationStrategy.

public <POOL extends Pool<T>> POOL

Returns:

the Pool
build
(Function<? super CONF, POOL>
the factory of pool implementation
poolFactory
)

Build a custom flavor of Pool, given a Pool factory Function that is provided with a PoolConfig copy of this builder's configuration.

pack-priv CONF
public InstrumentedPool<T>

Returns:

an InstrumentedPool
buildPool
()

Construct a default reactor pool with the builder's configuration.

public <
the type of decorated pool, must extend InstrumentedPool (with same type of resource)
P extends InstrumentedPool<T>
>
P

Returns:

the built-then-decorated pool
buildPoolAndDecorateWith
(Function<? super InstrumentedPool<T>, P>
a decorator Function returning a decorated version of the InstrumentedPool
decorator
)

Construct a default reactor pool with the builder's configuration, then wrap it into a decorator implementation using the provided Function.

public PoolBuilder<T, CONF>

Returns:

this Pool builder
clock
(Clock
the Clock to use to measure timestamps and durations
clock
)

Set the Clock to use for timestamps, notably marking the times at which a resource is allocated, released and acquired.

public PoolBuilder<T, CONF>

Returns:

this Pool builder
destroyHandler
(Function<T, ? extends Publisher<Void>>
the Function supplying the state-resetting Publisher
destroyHandler
)

Provide a handler that will derive a destroy Publisher whenever a resource isn't fit for usage anymore (either through eviction, manual invalidation, or because something went wrong with it).

public PoolBuilder<T, CONF>

Returns:

this Pool builder
evictInBackground
(Duration evictionInterval)

Enable background eviction so that evictionPredicate is regularly applied to elements that are idle in the pool when there is no pool activity (i.e. acquire and release).

public PoolBuilder<T, CONF>

Returns:

this Pool builder
evictInBackground
(Duration evictionInterval, Scheduler reaperTaskScheduler)

Enable background eviction so that evictionPredicate is regularly applied to elements that are idle in the pool when there is no pool activity (i.e. acquire and release).

public PoolBuilder<T, CONF>

Returns:

this Pool builder
evictInBackgroundDisabled
()

Disable background eviction entirely, so that evictionPredicate is only checked upon acquire and release (ie only when there is pool activity).

public PoolBuilder<T, CONF>

Returns:

this Pool builder
evictionIdle
(Duration
the Duration after which an object should not be passed to a borrower, but destroyed (resolution: ms)
maxIdleTime
)

Set the eviction predicate to cause eviction (ie returns true) of resources that have been idle (ie released and available in the Pool) for more than the ttl Duration (inclusive).

public PoolBuilder<T, CONF>

Returns:

this Pool builder
evictionPredicate
(BiPredicate<T, PooledRefMetadata>
a Predicate that returns true if the resource is unfit for the pool and should be destroyed, false if it should be put back into the pool
evictionPredicate
)

Provide an eviction BiPredicate that allows to decide if a resource is fit for being placed in the Pool.

public <
new type for the configuration
CONF2 extends PoolConfig<T>
>
PoolBuilder<T, CONF2>

Returns:

a new PoolBuilder that now produces a different type of PoolConfig
extraConfiguration
(Function<? super CONF, CONF2>
Function to transform the type of PoolConfig created by this builder for the benefit of the pool factory, allowing for custom implementations with custom configurations
configModifier
)

Add implementation-specific configuration, changing the type of PoolConfig passed to the Pool factory in build(Function).

public static <
the type of resource created and recycled by the Pool
T
>
PoolBuilder<T, PoolConfig<T>>

Returns:

a builder of Pool
from
(Publisher<? extends T>
the asynchronous creator of poolable resources, subscribed each time a new resource needs to be created.
allocator
)

Start building a Pool by describing how new objects are to be asynchronously allocated.

pack-priv static <T> BiPredicate<T, PooledRefMetadata>
idlePredicate(Duration maxIdleTime)

public PoolBuilder<T, CONF>

Returns:

this Pool builder
idleResourceReuseLruOrder
()

Configure the pool so that if there are idle resources (ie pool is under-utilized), the next Pool#acquire() will get the Least Recently Used resource (LRU, ie.

public PoolBuilder<T, CONF>

Returns:

this Pool builder
idleResourceReuseMruOrder
()

Configure the pool so that if there are idle resources (ie pool is under-utilized), the next Pool#acquire() will get the Most Recently Used resource (MRU, ie.

public PoolBuilder<T, CONF>

Returns:

this Pool builder
idleResourceReuseOrder
(boolean
true for LRU (the default) or false for MRU
isLru
)

Configure the order in which idle resources are used when the next Pool#acquire() is performed (while the pool is under-utilized).

public PoolBuilder<T, CONF>

Returns:

a builder of Pool with a maximum pending queue size.
maxPendingAcquire
(int
the maximum number of registered acquire monos to keep in a pending queue
maxPending
)

Set the maximum number of subscribed Pool#acquire() Monos that can be in a pending state (ie they wait for a resource to be released, as no idle resource was immediately available, and the pool add already allocated the maximum permitted amount).

public PoolBuilder<T, CONF>

Returns:

a builder of Pool with no maximum pending queue size
maxPendingAcquireUnbounded
()

Uncap the number of subscribed Pool#acquire() Monos that can be in a pending state (ie they wait for a resource to be released, as no idle resource was immediately available, and the pool add already allocated the maximum permitted amount).

public PoolBuilder<T, CONF>

Returns:

this Pool builder
metricsRecorder
(PoolMetricsRecorder recorder)

Set up the optional PoolMetricsRecorder for Pool to use for instrumentation purposes.

pack-priv static <T> BiPredicate<T, PooledRefMetadata>
pack-priv static <T> Function<T, Mono<Void>>
public PoolBuilder<T, CONF>

Returns:

this Pool builder
pendingAcquireTimer
(BiFunction<Runnable, Duration, Disposable>
the function to apply when scheduling timers for acquisitions that are added to the pending queue.
pendingAcquireTimer
)

Define how timeouts are scheduled when a Pool#acquire(Duration) call is made and the acquisition is pending.

public PoolBuilder<T, CONF>

Returns:

this Pool builder
releaseHandler
(Function<T, ? extends Publisher<Void>>
the Function supplying the state-resetting Publisher
releaseHandler
)

Provide a handler that will derive a reset Publisher whenever a resource is released.

public PoolBuilder<T, CONF>

Returns:

this Pool builder
sizeBetween
(int
the minimum number of live resources to keep in the pool (can be best effort)
min
,
int
the maximum number of live resources to keep in the pool. use Integer#MAX_VALUE when you only need a minimum and no upper bound
max
)

Replace the AllocationStrategy with one that lets the Pool allocate between min and max resources.

public PoolBuilder<T, CONF>

Returns:

this Pool builder
sizeBetween
(int
the minimum number of live resources to keep in the pool (can be best effort)
min
,
int
the maximum number of live resources to keep in the pool. use Integer#MAX_VALUE when you only need a minimum and no upper bound
max
,
int
Specifies the concurrency level used when the allocator is subscribed to during the warmup phase, if any. During warmup, resources that can be pre-allocated will be created eagerly, but at most warmupParallelism resources are subscribed to at the same time. A warmupParallelism of 1 means that pre-allocation of resources is achieved by sequentially subscribing to the allocator, waiting for a resource to be created before subscribing a next time to the allocator, and so on until the last allocation completes.
warmupParallelism
)

Replace the AllocationStrategy with one that lets the Pool allocate between min and max resources.

public PoolBuilder<T, CONF>

Returns:

this Pool builder
sizeUnbounded
()

Replace the AllocationStrategy with one that lets the Pool allocate new resources when no idle resource is available, without limit.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

acquisitionSchedulerback to summary
pack-priv Scheduler acquisitionScheduler
allocationStrategyback to summary
pack-priv AllocationStrategy allocationStrategy
allocatorback to summary
pack-priv final Mono<T> allocator
clockback to summary
pack-priv Clock clock
configModifierback to summary
pack-priv final Function<PoolConfig<T>, CONF> configModifier
DEFAULT_PENDING_ACQUIRE_TIMERback to summary
pack-priv static final BiFunction<Runnable, Duration, Disposable> DEFAULT_PENDING_ACQUIRE_TIMER
DEFAULT_WARMUP_PARALLELISMback to summary
pack-priv static final int DEFAULT_WARMUP_PARALLELISM
destroyHandlerback to summary
pack-priv Function<T, ? extends Publisher<Void>> destroyHandler
evictionBackgroundIntervalback to summary
pack-priv Duration evictionBackgroundInterval
evictionBackgroundSchedulerback to summary
pack-priv Scheduler evictionBackgroundScheduler
evictionPredicateback to summary
pack-priv BiPredicate<T, PooledRefMetadata> evictionPredicate
idleLruOrderback to summary
pack-priv boolean idleLruOrder
maxPendingback to summary
pack-priv int maxPending
metricsRecorderback to summary
pack-priv PoolMetricsRecorder metricsRecorder
NEVER_PREDICATEback to summary
pack-priv static final BiPredicate<?, ?> NEVER_PREDICATE
NOOP_HANDLERback to summary
pack-priv static final Function<?, Mono<Void>> NOOP_HANDLER
pendingAcquireTimerback to summary
pack-priv BiFunction<Runnable, Duration, Disposable> pendingAcquireTimer
releaseHandlerback to summary
pack-priv Function<T, ? extends Publisher<Void>> releaseHandler

Constructor Detail

PoolBuilderback to summary
pack-priv PoolBuilder(Mono<T> allocator, Function<PoolConfig<T>, CONF> configModifier)
PoolBuilderback to summary
pack-priv PoolBuilder(PoolBuilder<T, ?> source, Function<PoolConfig<T>, CONF> configModifier)

Method Detail

acquisitionSchedulerback to summary
public PoolBuilder<T, CONF> acquisitionScheduler(Scheduler acquisitionScheduler)

Provide a Scheduler that can optionally be used by a Pool to deliver its resources in a more deterministic (albeit potentially less efficient) way, thread-wise. Other implementations MAY completely ignore this parameter.

Defaults to Schedulers#immediate().

Parameters
acquisitionScheduler:Scheduler

the Scheduler on which to deliver acquired resources

Returns:PoolBuilder<T, CONF>

this Pool builder

allocationStrategyback to summary
public PoolBuilder<T, CONF> allocationStrategy(AllocationStrategy allocationStrategy)

Limits in how many resources can be allocated and managed by the Pool are driven by the provided AllocationStrategy. This is a customization escape hatch that replaces the last configured strategy, but most cases should be covered by the sizeBetween(int, int) or sizeUnbounded() pre-made strategies.

Without a call to any of these 3 methods, the builder defaults to an unbounded creation of resources, although it is not a recommended one.

Parameters
allocationStrategy:AllocationStrategy

the AllocationStrategy to use

Returns:PoolBuilder<T, CONF>

this Pool builder

See Also
sizeBetween(int, int), sizeUnbounded()
buildback to summary
public <POOL extends Pool<T>> POOL build(Function<? super CONF, POOL> poolFactory)

Build a custom flavor of Pool, given a Pool factory Function that is provided with a PoolConfig copy of this builder's configuration.

Parameters
poolFactory:Function<? super CONF, POOL>

the factory of pool implementation

Returns:POOL

the Pool

buildConfigback to summary
pack-priv CONF buildConfig()
buildPoolback to summary
public InstrumentedPool<T> buildPool()

Construct a default reactor pool with the builder's configuration.

Returns:InstrumentedPool<T>

an InstrumentedPool

buildPoolAndDecorateWithback to summary
public <P extends InstrumentedPool<T>> P buildPoolAndDecorateWith(Function<? super InstrumentedPool<T>, P> decorator)

Construct a default reactor pool with the builder's configuration, then wrap it into a decorator implementation using the provided Function.

Parameters
<P>
the type of decorated pool, must extend InstrumentedPool (with same type of resource)
decorator:Function<? super InstrumentedPool<T>, P>

a decorator Function returning a decorated version of the InstrumentedPool

Returns:P

the built-then-decorated pool

clockback to summary
public PoolBuilder<T, CONF> clock(Clock clock)

Set the Clock to use for timestamps, notably marking the times at which a resource is allocated, released and acquired. The Clock#millis() method is used for this purpose, which produces timestamps and durations in milliseconds for eg. the evictionPredicate(BiPredicate).

These durations can also be exported as metrics, through the metricsRecorder, but having a separate Clock separates the concerns and allows to disregard metrics without crippling eviction.

Parameters
clock:Clock

the Clock to use to measure timestamps and durations

Returns:PoolBuilder<T, CONF>

this Pool builder

destroyHandlerback to summary
public PoolBuilder<T, CONF> destroyHandler(Function<T, ? extends Publisher<Void>> destroyHandler)

Provide a handler that will derive a destroy Publisher whenever a resource isn't fit for usage anymore (either through eviction, manual invalidation, or because something went wrong with it). The destroy procedure is applied asynchronously and errors are swallowed.

Defaults to recognizing Disposable and java.io.Closeable elements and disposing them.

Parameters
destroyHandler:Function<T, ? extends Publisher<Void>>

the Function supplying the state-resetting Publisher

Returns:PoolBuilder<T, CONF>

this Pool builder

evictInBackgroundback to summary
public PoolBuilder<T, CONF> evictInBackground(Duration evictionInterval)

Enable background eviction so that evictionPredicate is regularly applied to elements that are idle in the pool when there is no pool activity (i.e. acquire and release).

Providing an evictionInterval of zero is similar to disabling background eviction.

Background eviction support is optional: although all vanilla reactor-pool implementations DO support it, other implementations MAY ignore it. The background eviction process can be implemented in a best effort fashion, backing off if it detects any pool activity.

Returns:PoolBuilder<T, CONF>

this Pool builder

See Also
evictInBackground(Duration, Scheduler)
evictInBackgroundback to summary
public PoolBuilder<T, CONF> evictInBackground(Duration evictionInterval, Scheduler reaperTaskScheduler)

Enable background eviction so that evictionPredicate is regularly applied to elements that are idle in the pool when there is no pool activity (i.e. acquire and release).

Providing an evictionInterval of zero is similar to disabling background eviction.

Background eviction support is optional: although all vanilla reactor-pool implementations DO support it, other implementations MAY ignore it. The background eviction process can be implemented in a best effort fashion, backing off if it detects any pool activity.

Returns:PoolBuilder<T, CONF>

this Pool builder

See Also
evictInBackground(Duration)
evictInBackgroundDisabledback to summary
public PoolBuilder<T, CONF> evictInBackgroundDisabled()

Disable background eviction entirely, so that evictionPredicate is only checked upon acquire and release (ie only when there is pool activity).

Returns:PoolBuilder<T, CONF>

this Pool builder

See Also
evictInBackground(Duration)
evictionIdleback to summary
public PoolBuilder<T, CONF> evictionIdle(Duration maxIdleTime)

Set the eviction predicate to cause eviction (ie returns true) of resources that have been idle (ie released and available in the Pool) for more than the ttl Duration (inclusive). Such a predicate could be used to evict too idle objects when next encountered by an Pool#acquire().

This replaces any evictionPredicate(BiPredicate) previously set. If you need to combine idle predicate with more custom logic, prefer directly providing a BiPredicate. Note that the idle predicate from this method is written as (poolable, meta) -> meta.idleTime() >= maxIdleTime.toMillis().

Parameters
maxIdleTime:Duration

the Duration after which an object should not be passed to a borrower, but destroyed (resolution: ms)

Returns:PoolBuilder<T, CONF>

this Pool builder

See Also
evictionPredicate(BiPredicate)
evictionPredicateback to summary
public PoolBuilder<T, CONF> evictionPredicate(BiPredicate<T, PooledRefMetadata> evictionPredicate)

Provide an eviction BiPredicate that allows to decide if a resource is fit for being placed in the Pool. This can happen whenever a resource is released back to the Pool (after it was processed by the releaseHandler(Function)), but also when being acquired from the pool (triggering a second pass if the object is found to be unfit, eg. it has been idle for too long). Finally, some pool implementations MAY implement a reaper thread mechanism that detect idle resources through this predicate and destroy them.

Defaults to never evicting (a BiPredicate that always returns false).

In case some asynchronous verification of the health of a resource is needed, one possible approach is to rely on Pool#acquire() and PooledRef#invalidate() instead of the evictionPredicate: performing the check in a flatMap after having acquired the resource, then further chain an invalidate call if the resource is not healthy. The acquisition should then be retried, and a good way of doing so is by continuing the invalidate call with a Mono#error(Throwable) with a custom exception which would trigger an outer Mono#retryWhen(Retry).

Parameters
evictionPredicate:BiPredicate<T, PooledRefMetadata>

a Predicate that returns true if the resource is unfit for the pool and should be destroyed, false if it should be put back into the pool

Returns:PoolBuilder<T, CONF>

this Pool builder

See Also
evictionIdle(Duration)
extraConfigurationback to summary
public <CONF2 extends PoolConfig<T>> PoolBuilder<T, CONF2> extraConfiguration(Function<? super CONF, CONF2> configModifier)

Add implementation-specific configuration, changing the type of PoolConfig passed to the Pool factory in build(Function).

Parameters
<CONF2>
new type for the configuration
configModifier:Function<? super CONF, CONF2>

Function to transform the type of PoolConfig created by this builder for the benefit of the pool factory, allowing for custom implementations with custom configurations

Returns:PoolBuilder<T, CONF2>

a new PoolBuilder that now produces a different type of PoolConfig

fromback to summary
public static <T> PoolBuilder<T, PoolConfig<T>> from(Publisher<? extends T> allocator)

Start building a Pool by describing how new objects are to be asynchronously allocated. Note that the Publisher allocator is subscribed to each time a new resource is needed and will be cancelled past the first received element (unless it is already a Mono).

Adapting from blocking code is only acceptable if ensuring the work is offset on another Scheduler (eg. a constructor materialized via Mono#fromCallable(Callable) should be augmented with Mono#subscribeOn(Scheduler)).

Parameters
<T>
the type of resource created and recycled by the Pool
allocator:Publisher<? extends T>

the asynchronous creator of poolable resources, subscribed each time a new resource needs to be created.

Returns:PoolBuilder<T, PoolConfig<T>>

a builder of Pool

idlePredicateback to summary
pack-priv static <T> BiPredicate<T, PooledRefMetadata> idlePredicate(Duration maxIdleTime)
idleResourceReuseLruOrderback to summary
public PoolBuilder<T, CONF> idleResourceReuseLruOrder()

Configure the pool so that if there are idle resources (ie pool is under-utilized), the next Pool#acquire() will get the Least Recently Used resource (LRU, ie. the resource that was released first among the current idle resources).

Returns:PoolBuilder<T, CONF>

this Pool builder

idleResourceReuseMruOrderback to summary
public PoolBuilder<T, CONF> idleResourceReuseMruOrder()

Configure the pool so that if there are idle resources (ie pool is under-utilized), the next Pool#acquire() will get the Most Recently Used resource (MRU, ie. the resource that was released last among the current idle resources).

Returns:PoolBuilder<T, CONF>

this Pool builder

idleResourceReuseOrderback to summary
public PoolBuilder<T, CONF> idleResourceReuseOrder(boolean isLru)

Configure the order in which idle resources are used when the next Pool#acquire() is performed (while the pool is under-utilized). Allows to chose between the Least Recently Used order when true (LRU, ie. the resource that was released first among the current idle resources, the default) and Most Recently Used order (MRU, ie. the resource that was released last among the current idle resources).

Parameters
isLru:boolean

true for LRU (the default) or false for MRU

Returns:PoolBuilder<T, CONF>

this Pool builder

See Also
idleResourceReuseLruOrder(), idleResourceReuseMruOrder()
maxPendingAcquireback to summary
public PoolBuilder<T, CONF> maxPendingAcquire(int maxPending)

Set the maximum number of subscribed Pool#acquire() Monos that can be in a pending state (ie they wait for a resource to be released, as no idle resource was immediately available, and the pool add already allocated the maximum permitted amount). Set to 0 to immediately fail all such acquisition attempts. Set to -1 to deactivate (or prefer using the more explicit maxPendingAcquireUnbounded()).

Default to -1.

Parameters
maxPending:int

the maximum number of registered acquire monos to keep in a pending queue

Returns:PoolBuilder<T, CONF>

a builder of Pool with a maximum pending queue size.

maxPendingAcquireUnboundedback to summary
public PoolBuilder<T, CONF> maxPendingAcquireUnbounded()

Uncap the number of subscribed Pool#acquire() Monos that can be in a pending state (ie they wait for a resource to be released, as no idle resource was immediately available, and the pool add already allocated the maximum permitted amount).

This is the default.

Returns:PoolBuilder<T, CONF>

a builder of Pool with no maximum pending queue size

metricsRecorderback to summary
public PoolBuilder<T, CONF> metricsRecorder(PoolMetricsRecorder recorder)

Set up the optional PoolMetricsRecorder for Pool to use for instrumentation purposes.

Parameters
recorder:PoolMetricsRecorder

the PoolMetricsRecorder

Returns:PoolBuilder<T, CONF>

this Pool builder

neverPredicateback to summary
pack-priv static <T> BiPredicate<T, PooledRefMetadata> neverPredicate()
Annotations
@SuppressWarnings:unchecked
noopHandlerback to summary
pack-priv static <T> Function<T, Mono<Void>> noopHandler()
Annotations
@SuppressWarnings:unchecked
pendingAcquireTimerback to summary
public PoolBuilder<T, CONF> pendingAcquireTimer(BiFunction<Runnable, Duration, Disposable> pendingAcquireTimer)

Define how timeouts are scheduled when a Pool#acquire(Duration) call is made and the acquisition is pending. i.e. there is no idle resource and no new resource can be created currently, so a timeout is scheduled using the provided function.

By default, the Schedulers#parallel() scheduler is used.

Parameters
pendingAcquireTimer:BiFunction<Runnable, Duration, Disposable>

the function to apply when scheduling timers for acquisitions that are added to the pending queue.

Returns:PoolBuilder<T, CONF>

this Pool builder

releaseHandlerback to summary
public PoolBuilder<T, CONF> releaseHandler(Function<T, ? extends Publisher<Void>> releaseHandler)

Provide a handler that will derive a reset Publisher whenever a resource is released. The reset procedure is applied asynchronously before vetting the object through evictionPredicate. If the reset Publisher couldn't put the resource back in a usable state, it will be destroyed.

Defaults to not resetting anything.

Parameters
releaseHandler:Function<T, ? extends Publisher<Void>>

the Function supplying the state-resetting Publisher

Returns:PoolBuilder<T, CONF>

this Pool builder

sizeBetweenback to summary
public PoolBuilder<T, CONF> sizeBetween(int min, int max)

Replace the AllocationStrategy with one that lets the Pool allocate between min and max resources. When acquiring and there is no available resource, the pool should strive to warm up enough resources to reach min live resources before serving the acquire with (one of) the newly created resource(s). At the same time it MUST NOT allocate any resource if that would bring the number of live resources over the max, rejecting further allocations until some resources have been released.

Pre-allocation of warmed-up resources, if any, will be performed sequentially by subscribing to the allocator one at a time. The process waits for a resource to be created before subscribing again to the allocator. This sequence continues until all pre-allocated resources have been successfully created.

Parameters
min:int

the minimum number of live resources to keep in the pool (can be best effort)

max:int

the maximum number of live resources to keep in the pool. use Integer#MAX_VALUE when you only need a minimum and no upper bound

Returns:PoolBuilder<T, CONF>

this Pool builder

See Also
sizeUnbounded(), allocationStrategy(AllocationStrategy)
sizeBetweenback to summary
public PoolBuilder<T, CONF> sizeBetween(int min, int max, int warmupParallelism)

Replace the AllocationStrategy with one that lets the Pool allocate between min and max resources. When acquiring and there is no available resource, the pool should strive to warm up enough resources to reach min live resources before serving the acquire with (one of) the newly created resource(s). At the same time it MUST NOT allocate any resource if that would bring the number of live resources over the max, rejecting further allocations until some resources have been released.

Parameters
min:int

the minimum number of live resources to keep in the pool (can be best effort)

max:int

the maximum number of live resources to keep in the pool. use Integer#MAX_VALUE when you only need a minimum and no upper bound

warmupParallelism:int

Specifies the concurrency level used when the allocator is subscribed to during the warmup phase, if any. During warmup, resources that can be pre-allocated will be created eagerly, but at most warmupParallelism resources are subscribed to at the same time. A warmupParallelism of 1 means that pre-allocation of resources is achieved by sequentially subscribing to the allocator, waiting for a resource to be created before subscribing a next time to the allocator, and so on until the last allocation completes.

Returns:PoolBuilder<T, CONF>

this Pool builder

Since
1.0.1
See Also
sizeUnbounded(), allocationStrategy(AllocationStrategy)
sizeUnboundedback to summary
public PoolBuilder<T, CONF> sizeUnbounded()

Replace the AllocationStrategy with one that lets the Pool allocate new resources when no idle resource is available, without limit.

Note this is the default, if no previous call to allocationStrategy(AllocationStrategy) or sizeBetween(int, int) has been made on this PoolBuilder.

Returns:PoolBuilder<T, CONF>

this Pool builder

See Also
sizeBetween(int, int), allocationStrategy(AllocationStrategy)