|
Lightweight 0.20260921.0
|
#include <Pool.hpp>
Public Member Functions | |
| constexpr std::chrono::milliseconds | MaxIdleTime () const noexcept |
| constexpr std::chrono::milliseconds | MaxLifetime () const noexcept |
Public Attributes | |
| size_t | initialSize {} |
| Initial number of data mappers to pre-create and store in the pool, must be less than or equal to maxSize. | |
| size_t | maxSize {} |
| GrowthStrategy | growthStrategy { GrowthStrategy::BoundedWait } |
| ValidateOnBorrow | validateOnBorrow { ValidateOnBorrow::Yes } |
| std::chrono::milliseconds::rep | maxIdleTimeMs {} |
| std::chrono::milliseconds::rep | maxLifetimeMs {} |
| size_t | preparedStatementCacheCapacity { PreparedStatementCacheCapacityDefault } |
Structure to hold the configuration of the pool, including the initial size, maximum size and growth strategy. Structure is used as a template parameter for the Pool class to configure its behavior at compile time.
std::chrono::milliseconds because this structure is used as a non-type template parameter: std::chrono::duration keeps its representation private and is therefore not a structural type. Use PoolConfig::MaxIdleTime and PoolConfig::MaxLifetime to read them back as durations.
|
inlineconstexprnoexcept |
Definition at line 147 of file Pool.hpp.
References maxIdleTimeMs.
|
inlineconstexprnoexcept |
Definition at line 153 of file Pool.hpp.
References maxLifetimeMs.
| size_t Lightweight::PoolConfig::initialSize {} |
| size_t Lightweight::PoolConfig::maxSize {} |
Maximum number of data mappers that can exist in the pool, must be greater than or equal to initialSize this is used for the Bounded* strategies to determine when to block or when to stop accepting returned data mappers, for the UnboundedGrow strategy this is ignored
| GrowthStrategy Lightweight::PoolConfig::growthStrategy { GrowthStrategy::BoundedWait } |
| ValidateOnBorrow Lightweight::PoolConfig::validateOnBorrow { ValidateOnBorrow::Yes } |
Whether a connection is checked for liveness before it is handed to a caller, enabled by default.
| std::chrono::milliseconds::rep Lightweight::PoolConfig::maxIdleTimeMs {} |
Maximum time in milliseconds a connection may sit idle in the pool before it is retired instead of handed out again; 0 (the default) disables the bound.
Set this below any idle timeout imposed by the network path (a firewall or NAT dropping idle flows) or by the server, so a connection is never idle long enough to be reaped behind the pool's back. This removes the failure mode that ValidateOnBorrow can only detect, and then only when the driver has noticed.
Definition at line 120 of file Pool.hpp.
Referenced by MaxIdleTime().
| std::chrono::milliseconds::rep Lightweight::PoolConfig::maxLifetimeMs {} |
Maximum total age in milliseconds of a connection, counted from when it was created, after which it is retired rather than reused; 0 (the default) disables the bound.
Unlike validateOnBorrow, this retires connections that are perfectly alive but no longer appropriate: after a failover or a rolling restart a pooled connection stays bound to the old node, and nothing else in the pool will ever move it. Setting this shorter than any connection-age ceiling imposed by the database or the infrastructure also means connections are retired while idle, which is free, rather than being cut mid-query by something else.
Definition at line 132 of file Pool.hpp.
Referenced by MaxLifetime().
| size_t Lightweight::PoolConfig::preparedStatementCacheCapacity { PreparedStatementCacheCapacityDefault } |
Prepared-statement cache capacity given to the connection of every data mapper this pool creates, i.e. how many already-prepared ODBC statement handles that connection keeps for reuse. Zero (the default) leaves the cache disabled, exactly as an unpooled connection.
The bound is per connection, not per pool: a pool may hold up to maxSize connections, each with its own cache of this size, so the live prepared handles a fully warmed pool holds on the server are maxSize * preparedStatementCacheCapacity. Size it against the backend's per-session limit on prepared statements, not against the number of distinct queries alone.