bullmq - v6.4.0
    Preparing search index...

    Interface IRelayBackendExperimental

    IRelayBackend

    Datastore-agnostic contract used by the Relay. Every operation is implemented as a single atomic Lua script (Redis) or SQL function (PostgreSQL), so the routing logic is shared verbatim by every BullMQ runtime. Implementations only translate arguments and results.

    Errors are thrown as RelayError with one of the shared codes.

    The contract may change in minor releases while the relay is completed.

    interface IRelayBackend {
        initialInboxCursor: string;
        namespace: string;
        close(): Promise<void>;
        deleteRetained(topic: string): Promise<boolean>;
        getCounts(): Promise<RelayCounts>;
        getNamespaces(): Promise<string[]>;
        getNodeConnections(nodeId: string): Promise<RelayNodeConnection[]>;
        getNodes(start: number, end: number): Promise<RelayNodeState[]>;
        getPatterns(start: number, end: number): Promise<RelayPatternState[]>;
        getRetained(start: number, end: number): Promise<RelayRetainedState[]>;
        getSubscriptions(
            filter: RelaySubscriptionFilter,
            start: number,
            end: number,
        ): Promise<RelaySubscriptionState[]>;
        heartbeat(nodeId: string, leaseMs: number): Promise<boolean>;
        interruptInbox(): void;
        publish(
            topic: string,
            data: string,
            opts: RelayPublishOptions,
        ): Promise<RelayPublishResult>;
        readInbox(
            nodeId: string,
            cursor: string,
            opts: { blockMs: number; count: number },
        ): Promise<RelayInboxBatch>;
        registerNode(
            nodeId: string,
            leaseMs: number,
            info?: RelayNodeInfo,
            inboxMaxLength?: number,
        ): Promise<void>;
        removeEndpoint(nodeId: string, endpointId: string): Promise<number>;
        subscribe(
            nodeId: string,
            endpointId: string,
            pattern: string,
        ): Promise<RelaySubscribeResult>;
        sweep(limit: number): Promise<string[]>;
        trimInbox(
            nodeId: string,
            cursor: string,
            maxLength: number,
        ): Promise<number>;
        unregisterNode(nodeId: string): Promise<boolean>;
        waitUntilReady(): Promise<void>;
    }

    Implemented by

    Index
    initialInboxCursor: string

    Position from which a freshly registered node reads its inbox.

    namespace: string
    • Experimental

      Deletes the retained message of a topic.

      Parameters

      • topic: string

      Returns Promise<boolean>

      false if the topic had no retained message.

    • 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

      Namespaces of the datastore (or Redis prefix) with live nodes or retained messages, sorted by name.

      Returns Promise<string[]>

    • Experimental

      The inbox connection of a node, as the datastore sees it (from CLIENT LIST or pg_stat_activity): where it connects from, and for how long. Empty when the node isn't connected. Lists every client connection of the datastore, so use it on demand rather than polling it.

      Parameters

      • nodeId: string

      Returns Promise<RelayNodeConnection[]>

    • 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

      Makes a blocked readInbox return (or fail) promptly, and later reads stop waiting. Used on close, so an interrupt that lands while a read is still starting is not lost.

      Returns void

    • 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

      Registers (or refreshes) a node, its liveness lease and its info.

      Parameters

      • nodeId: string
      • leaseMs: number
      • Optionalinfo: RelayNodeInfo
      • OptionalinboxMaxLength: number

      Returns Promise<void>

    • Experimental

      Parameters

      • nodeId: string
      • endpointId: string

      Returns Promise<number>

      the number of subscriptions removed.

    • 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).

    • Experimental

      Removes a node with its subscriptions and inbox.

      Parameters

      • nodeId: string

      Returns Promise<boolean>