bullmq - v6.2.0
    Preparing search index...

    Class PostgresConnection

    Owns the PostgreSQL connection resources for a single backend:

    • a pg.Pool for regular, short-lived queries, and
    • a dedicated, long-lived LISTEN client used by the blocking "wait for job" primitive (lazily established).

    Lifecycle mirrors RedisConnection: it is an EventEmitter that surfaces normalized 'ready' | 'error' | 'close' events and exposes PostgresConnection.waitUntilReady and PostgresConnection.close.

    Hierarchy

    • EventEmitter
      • PostgresConnection
    Index
    pool: PgPool
    schema: string

    The PostgreSQL schema (namespace) this connection's queues live in. It is applied to every pooled connection's search_path, so the .sql command files (and the operation functions) reference unqualified names and stay portable — the schema selects the namespace, never the SQL itself.

    • Closes the connection: releases the LISTEN client and (if owned) ends the pool. Safe to call multiple times.

      Returns Promise<void>

    • Returns the dedicated client used for LISTEN/NOTIFY, establishing it on first use.

      When this connection owns the pool we use a standalone pg.Client (its own dedicated TCP connection) so the long-lived LISTEN never consumes a pool slot — this is what lets the query pool run at max: 1 without deadlocking. When the user supplied their own pg.Pool we check a client out of it (so such pools should be sized >= 2).

      Returns Promise<PgListenClient>

    • Resolves once the pool is reachable and the schema is compatible.

      Idempotent and memoized. By default this only reads the migration ledger. When migrate: true was configured, migrations run on one checked-out client so their advisory lock and transaction share a session.

      Returns Promise<void>