/** * A dedicated, self-healing Postgres `LISTEN` connection. * * Every cross-instance feature in the backend needs the same thing: one * connection *outside* the Drizzle pool that stays open, holds a `LISTEN`, and * comes back on its own after the database or the network drops it. CDC needed * it first; the channel bus needs it too. This is that connection, with the one * behaviour that matters to callers preserved: the **first** connect is * validated and rethrown, so a caller can fall back to a different strategy, * while every later drop is repaired quietly in the background. * * `LISTEN` is session state, so this connection must not go through a * transaction-mode pooler (PgBouncer): give it the direct database URL. */ export interface PgNotifyListenerOptions { /** Direct Postgres connection string (must bypass a transaction-mode pooler). */ connectionString: string; /** NOTIFY channel to LISTEN on. Must be a plain identifier — it is interpolated. */ channel: string; /** Called for every notification payload received. */ onPayload: (payload: string) => void | Promise; /** Prefix for log lines, e.g. `"[CDC]"`. */ logLabel: string; /** Delay before a reconnect attempt. */ reconnectDelayMs?: number; } export declare class PgNotifyListener { private readonly options; private client?; private running; private reconnectTimer?; constructor(options: PgNotifyListenerOptions); /** Whether the listener is meant to be connected right now. */ get active(): boolean; /** * Connect and begin listening. Idempotent. * * Rejects if the *initial* connection or `LISTEN` fails, leaving the * listener stopped — callers use that to degrade deliberately instead of * running blind against a channel nothing is delivering. */ start(): Promise; /** Stop listening and release the connection. Idempotent. */ stop(): Promise; private connect; private scheduleReconnect; }