Class InMemoryOutbox

Outbound deliveries in memory, for tests and single-process hosts.

Implements

Constructors

Methods

  • Optional whole-run eviction for in-memory hosts after terminal cleanup and the retention grace. Durable stores omit it to retain their records. Call only after producers have stopped; forgetting removes fences too.

    Parameters

    • runId: string

    Returns Promise<void>

  • Adds a pending delivery, due at now; a repeated id preserves the first delivery and its retry state. After purgeContent for the run, a delivery of a content event (a type in CONTENT_EVENT_TYPES) is not stored: the purge is the outbox's fence. A delivery of any other type (bot:left, bot:purged, bot:done and the rest) is stored. A mail delivery (kind: 'mail') is content: behind the fence it is stored empty and dead, and purgeContent empties it with the content events.

    Parameters

    Returns Promise<void>

  • Records a failed attempt: due again after the backoff of nextAttemptAt, or dead a day after the first failed attempt, or at a mail delivery's expiry (its body emptied). A delivery that is no longer pending, delivered or dead, is left as it is.

    Parameters

    • id: string
    • now: number

    Returns Promise<void>

  • Optional (the library's stores have it). Ends a pending delivery at once (a destination's permanent refusal, or an outcome the destination never answered), a mail's body emptied; one no longer pending is left as it is. True when the outbox recorded it; false from a wrapper whose outbox cannot, whose caller records a failed attempt instead.

    Parameters

    • id: string

    Returns Promise<boolean>

  • Optional (the library's stores have it). Moves a pending delivery's next attempt to notBefore without counting an attempt (a cap that holds it). True when recorded; false from a wrapper whose outbox cannot.

    Parameters

    • id: string
    • notBefore: number

    Returns Promise<boolean>

  • Optional (the library's stores have it). Ends every pending delivery of the run to the destination (an address that declined), their bodies emptied. True when recorded; false from a wrapper whose outbox cannot.

    Parameters

    • runId: string
    • destinationRef: string

    Returns Promise<boolean>

  • Optional (the library's stores have it). Ends every pending mail delivery whose expiry has passed at now, dead with its body emptied, so an expired body waits for no attempt; the count ended. OutboxDispatcher calls it at the start of each pass.

    Parameters

    • now: number

    Returns Promise<number>

  • Makes a delivery pending again, due at now, with its attempts counted afresh (a manual replay); a mail delivery is never replayed, and the call changes nothing.

    Parameters

    • id: string
    • now: number

    Returns Promise<void>

  • Empties every content delivery of the run (a type in CONTENT_EVENT_TYPES), delivered ones included, so a replay after a purge sends the content-free bot:purged in its place. A delivery of any other type (bot:done, bot:left and the rest) carries no content and keeps its type and payload. From then on the run takes no content delivery (see enqueue).

    Parameters

    • runId: string

    Returns Promise<void>

  • Sends one delivery as the outbox holds it now, not as due returned it: one gone or no longer pending is skipped (false). The signal send gets aborts when purgeContent purges the delivery's run, so a send that has not written its body yet stops (false); any other rejection is send's.

    Parameters

    • candidate: OutboxDelivery

      A delivery due returned.

    • send: ((fresh, signal) => Promise<void>)

      Sends the fresh copy under the signal.

        • (fresh, signal): Promise<void>
        • Parameters

          Returns Promise<void>

    Returns Promise<boolean>