PgPool unstable
Pools of native PgConnection sessions.
Constructors
Creates a scoped PostgreSQL session pool.
Details
Connections are opened lazily up to maxConnections and released down to
minConnections after idleTimeout without use. A retired session stops
being handed out immediately, but its slot is held until its transport
closes. Closing the scope shuts the pool down and releases every session.
When tracing is enabled, each session attempt emits a root sql.connect
client span. With SpanPropagationEnabled, a statement that waited for a
new session gets a db.connect child span covering the part of the connect
it waited for, linked to that attempt span.
Signature
declare const make: (...args: [options: Config]) => Effect<PgPool, SqlError, Scope>Models
Connection and sizing settings for a PostgreSQL session pool.
Details
The defaults are 0 to 10 connections and a 60-second idle timeout.
connectionTTL replaces connections that exceed the configured lifetime.
A retired session keeps its maxConnections slot until its transport closes.
Every connection is used at least once, so a TTL of zero disables reuse.
acquireTimeout bounds how long a checkout takes to acquire a connection,
including opening a new one; by default it waits indefinitely.
With multiplex enabled, fibers may share pooled connections for pipelined
queries. Reserved connections remain exclusive. Without multiplexing, every
checkout is exclusive.
Signature
interface Config extends Config { readonly acquireTimeout?: Input; readonly connectionTTL?: Input; readonly connectRetrySchedule?: Schedule<unknown, SqlError, never, never>; readonly idleTimeout?: Input; readonly maxConnections?: number; readonly minConnections?: number; readonly multiplexConcurrency?: number;}A PostgreSQL session pool.
Signature
interface PgPool { readonly "~@effect/sql-pg/PgPool": "~@effect/sql-pg/PgPool"; readonly config: Config; readonly get: Effect<PgConnection, SqlError, Scope>; readonly invalidate: (connection: PgConnection) => Effect<void>; readonly reserve: Effect<PgConnection, SqlError, Scope>; readonly stats: Effect<Stats>; readonly use: <A, E, R>(f: (connection: PgConnection) => Effect<A, E, R>) => Effect<A, SqlError | E, R>;}