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. Closing the scope shuts
the pool down and releases every session.
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.
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.
Every connection is used at least once, so a TTL of zero disables reuse.
acquireTimeout bounds how long a checkout waits for a free connection;
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 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 use: <A, E, R>(f: (connection: PgConnection) => Effect<A, E, R>) => Effect<A, SqlError | E, R>;}