Top Description Methods
reactor.pool

public Interface PooledRef<POOLABLE>

Known Direct Implementers
reactor.pool.decorators.GracefulShutdownInstrumentedPool.GracefulRef, reactor.pool.AbstractPool.AbstractPooledRef
Imports
reactor.core.publisher.Mono, java.util.function.Function

An abstraction over an object in a Pool, which holds the underlying POOLABLE object and allows one to manually release() it to the pool or invalidate() it. Through its metadata(), the PooledRef provides a few additional information about its lifecycle, like its age and the number of times it has been acquired, so the Pool may optionally use that information to automatically invalidate the object, and provide a simplified acquire mechanism where the PooledRef is not directly exposed (see Pool#withPoolable(Function) vs Pool#acquire()).
Author
Simon Baslé

Method Summary

Modifier and TypeMethod and Description
public Mono<Void>
invalidate()

Return a Mono that triggers the asynchronous invalidation of the POOLABLE when subscribed.

public PooledRefMetadata

Returns:

the PooledRefMetadata for this PooledRef
metadata
()

Returns a PooledRefMetadata object that holds more information about the reference (rather than the poolable()), like how many times it was acquired, its age (time since allocation), etc...

public POOLABLE

Returns:

the poolable
poolable
()

Returns the wrapped POOLABLE.

public Mono<Void>

Returns:

a Mono that will complete empty when the object has been released. In case of an error the object is always discarded
release
()

Return a Mono that, once subscribed, will release the POOLABLE back to the pool asynchronously.

Method Detail

invalidateback to summary
public Mono<Void> invalidate()

Return a Mono that triggers the asynchronous invalidation of the POOLABLE when subscribed. The object is always discarded by the pool and not further reused.

This is useful when the unhealthy state of the resource (or lack of re-usability) is detected through the usage of the resource, as opposed to its exposed state.

Note that if release() has been invoked, this method should be no-op.

metadataback to summary
public PooledRefMetadata metadata()

Returns a PooledRefMetadata object that holds more information about the reference (rather than the poolable()), like how many times it was acquired, its age (time since allocation), etc...

Note that if release() or invalidate() have been invoked, this method might return stale information.

Returns:PooledRefMetadata

the PooledRefMetadata for this PooledRef

poolableback to summary
public POOLABLE poolable()

Returns the wrapped POOLABLE. This method is not thread-safe and the poolable should NEVER be accessed concurrently.

The reference is retained by the PooledRef but the object might be in an intermediate or invalid state when one of the release() or invalidate() methods have been previously called.

Returns:POOLABLE

the poolable

releaseback to summary
public Mono<Void> release()

Return a Mono that, once subscribed, will release the POOLABLE back to the pool asynchronously. Once released, a reference is considered out of the control of the user and shouldn't be usable anymore. It is discouraged to use the underlying poolable() at this point, metadata() might become stale, and usage of both invalidate() and release() should be no-op.

This method is idempotent (subsequent subscriptions to the same Mono, or re-invocations of the method are NO-OP). It is also no-op if invalidate() has previously been invoked.

Returns:Mono<Void>

a Mono that will complete empty when the object has been released. In case of an error the object is always discarded