@pwngh/economy-lab
    Preparing search index...

    Interface OutboxStore

    A transactional outbox: events save in the same database transaction as the money move, so an event is never sent for a rolled-back move nor lost for a committed one.

    interface OutboxStore {
        claimBatch(
            limit: number,
            options?: CallOptions,
        ): Promise<readonly OutboxMessage[]>;
        deadLetter(
            id: string,
            reason: string,
            options?: CallOptions,
        ): Promise<void>;
        enqueue(message: OutboxMessage, options?: CallOptions): Promise<void>;
        markRelayed(ids: readonly string[], options?: CallOptions): Promise<void>;
        recordFailure(id: string, options?: CallOptions): Promise<void>;
        stats(options?: CallOptions): Promise<OutboxStats>;
    }
    Index
    • Grabs up to limit pending messages, each locked so a concurrent relay picks different ones. A 'relayed' or 'dead' row is terminal and never re-claimed.

      Parameters

      Returns Promise<readonly OutboxMessage[]>

    • Sets status 'dead' so claimBatch never returns it again, recording reason for operators; a non-existent or already-terminal row is left untouched.

      Parameters

      • id: string
      • reason: string
      • Optionaloptions: CallOptions

      Returns Promise<void>

    • Delivery may still double-send, so the consumer drops duplicates by message id.

      Parameters

      Returns Promise<void>

    • Bumps attempts and leaves the row 'pending'; only deadLetter may flip the status.

      Parameters

      Returns Promise<void>

    • A read-only gauge of the pending backlog: how many rows wait and how old the oldest is. Age is computed on the store's own time base, so an app/database clock skew never distorts it. The relay sweep observes this each run — a backlog that only grows means the relay is down or the events are poisoned.

      Parameters

      Returns Promise<OutboxStats>