PgPool
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.
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 10-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.
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 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>;}