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

    Interface IdempotencyStore

    Makes a repeated request run at most once, keyed by the caller's idempotency key.

    interface IdempotencyStore {
        claim(
            key: string,
            options?: CallOptions,
        ): Promise<
            { claimed: true }
            | { claimed: false; transaction: Transaction },
        >;
        deleteOlderThan?(
            cutoffMs: number,
            limit: number,
            options?: CallOptions,
        ): Promise<number>;
        record(
            key: string,
            transaction: Transaction,
            options?: CallOptions,
        ): Promise<void>;
    }
    Index
    • Stakes a claim on a key: a claim on an in-flight key waits for its owner, a committed key replays the recorded transaction as { claimed: false }, and a rolled-back key is granted fresh as { claimed: true }.

      Parameters

      Returns Promise<{ claimed: true } | { claimed: false; transaction: Transaction }>

    • Retention (src/worker/retention.ts): deletes up to limit rows created before cutoffMs, oldest first, returning the count. A deleted key is open again — a duplicate request re-executes — so the caller's horizon must exceed every client retry window. Optional; a store without it skips the idempotency retention lane.

      Parameters

      • cutoffMs: number
      • limit: number
      • Optionaloptions: CallOptions

      Returns Promise<number>

    • Called inside the posting's transaction, so it only takes effect if the posting commits.

      Parameters

      Returns Promise<void>