← Back to Stormify Documentation

PoolConfig

data class PoolConfig(val minConnections: Int = 2, val maxConnections: Int = 10, val acquireTimeout: Duration = 30.seconds, val idleTimeout: Duration = 5.minutes, val maxLifetime: Duration = 30.minutes, val cleanupInterval: Duration = 30.seconds, val validationQuery: String? = null, val validateAfterIdle: Duration = 10.seconds, val shutdownTimeout: Duration = 30.seconds)

Configuration for SuspendConnectionPool.

All durations use kotlin.time.Duration. All validations in init are intentionally strict — it is better to fail fast with a clear message than to produce a pool with pathological behaviour at runtime.

Constructors

Link copied to clipboard
constructor(minConnections: Int = 2, maxConnections: Int = 10, acquireTimeout: Duration = 30.seconds, idleTimeout: Duration = 5.minutes, maxLifetime: Duration = 30.minutes, cleanupInterval: Duration = 30.seconds, validationQuery: String? = null, validateAfterIdle: Duration = 10.seconds, shutdownTimeout: Duration = 30.seconds)

Properties

Link copied to clipboard

Maximum time to wait for a free connection when the pool is saturated. On timeout, SuspendConnectionPool.use throws PoolAcquireTimeoutException.

Link copied to clipboard

How often the background cleanup coroutine runs idle/lifetime sweeps. Smaller values release dead connections sooner at the cost of more wake-ups.

Link copied to clipboard

A connection that has been idle longer than this is eligible for eviction by the background cleanup coroutine. Connections down to minConnections are always preserved, regardless of idle time.

Link copied to clipboard

Hard upper bound on concurrent connections. A caller that tries to acquire when the pool is saturated will suspend (not block a thread) until another caller releases or acquireTimeout elapses.

Link copied to clipboard

Absolute lifetime of a connection from creation to forced retirement, regardless of activity. Prevents long-lived sessions from accumulating server-side state (prepared statement cache growth, session-level temp tables, etc.). Set to Duration.INFINITE to disable max-lifetime retirement.

Link copied to clipboard

Minimum number of connections kept open in the pool at all times, even when idle. The pool pre-populates to this size on first use. Set to 0 to disable warm-up.

Link copied to clipboard

Graceful-shutdown grace period. When SuspendConnectionPool.close is invoked the pool stops accepting new acquires and waits up to this long for in-flight use { } blocks to return their connections before forcibly closing what remains.

Link copied to clipboard

Skip validation for connections released within this window. A just-returned connection is very likely still alive; validating every borrow wastes round-trips.

Link copied to clipboard

Optional SQL that validates a connection before handing it to a caller. If null, no validation is performed — the pool relies on SuspendConnectionPool.use to evict connections that raise errors during use. Typical values: "SELECT 1" (most databases), "SELECT 1 FROM DUAL" (Oracle).