bullmq - v6.4.0
    Preparing search index...

    Class PostgresRelayBackend

    PostgreSQL implementation of IRelayBackend. Every operation is one of the relay_* SQL functions (migration 0004_relay); this class only passes arguments and decodes rows.

    Rows have no expiry in PostgreSQL: sweeps remove expired nodes (with their subscriptions and inboxes) and retained messages of every namespace, so a namespace whose nodes all vanished is cleaned by any node using the same schema.

    Each node's inbox is a table, read after a NOTIFY on the bullmq_relay channel (or after the wait times out, so a missed notification only delays delivery). Entries are acknowledged by id, which never skips a row whose transaction committed late.

    Hierarchy

    • EventEmitter
      • PostgresRelayBackend

    Implements

    Index
    initialInboxCursor: "" = ''

    Position from which a freshly registered node reads its inbox.

    namespace: string
    • Experimental

      Read-only getters, for dashboards. Lists are paginated like the queue getters: start and end are inclusive positions (from 0), and an end of -1 means "to the end". Orders are stable: nodes by registration, subscriptions and patterns by value (bytewise), retained messages by expiry.

      Returns Promise<RelayCounts>

    • Experimental

      Renews a node's lease.

      Parameters

      • nodeId: string
      • leaseMs: number

      Returns Promise<boolean>

      false when the node is not registered or its lease expired, even if it was not swept. The caller must register again and restore its subscriptions.

    • Experimental

      Returns the next entries of a node's inbox, waiting up to blockMs when there are none (0: return immediately).

      Parameters

      • nodeId: string
      • cursor: string
      • opts: { blockMs: number; count: number }

      Returns Promise<RelayInboxBatch>

    • Experimental

      Removes up to limit nodes whose lease expired, with their subscriptions and inboxes.

      Parameters

      • limit: number

      Returns Promise<string[]>

      the ids of the removed nodes.

    • Experimental

      Removes the entries of a node's inbox that were already consumed (up to cursor, as returned by readInbox) and the oldest entries beyond maxLength.

      Parameters

      • nodeId: string
      • cursor: string
      • maxLength: number

      Returns Promise<number>

      the number of entries left: the messages the node hasn't read yet (its backlog).