Class InMemoryJobStore

Dispatch jobs in memory, for tests and single-process hosts: its leases hold within one process.

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 the run's job, due at dispatchAt; for an existing job moves only dispatchAt, preserving the lease, worker, dispatched and cancelled fields.

    Parameters

    • job: {
          runId: string;
          dispatchAt: number;
      }
      • runId: string
      • dispatchAt: number

    Returns Promise<void>

  • Extends a lease the holder still holds; false when it expired or another holder took it, and then the holder must stop.

    Parameters

    • runId: string
    • holder: string
    • now: number
    • ttlMs: number

    Returns Promise<boolean>

  • Records the dispatch for the lease's holder and answers whether a cancel arrived meanwhile (then the dispatcher tells the bot to leave at once). A dispatch can outlive its lease and another holder can take the job: when holder no longer holds the lease, or the job is gone, nothing is recorded and recorded is false.

    Parameters

    • runId: string
    • holder: string
    • workerId: undefined | string

    Returns Promise<{
        recorded: boolean;
        cancelled: boolean;
    }>

  • Releases the holder's lease without dispatching (the dispatch failed and will be retried), moving the job's due time to retryAt. False, and nothing changes, when holder no longer holds the lease or the job is gone.

    Parameters

    • runId: string
    • holder: string
    • retryAt: number

    Returns Promise<boolean>

  • Marks the job cancelled. already_dispatched when the bot is out: the caller tells it to leave instead. A job under a live lease is cancelled too, and its dispatcher learns it from markDispatched.

    Parameters

    • runId: string

    Returns Promise<"cancelled" | "already_dispatched" | "missing">