Skip to main content

InMemoryReplayLedger

@totemsdk/edge


@totemsdk/edge / InMemoryReplayLedger

Class: InMemoryReplayLedger

In-memory replay ledger (dev/test). Atomic within a single process.

Implements

Constructors

Constructor

new InMemoryReplayLedger(): InMemoryReplayLedger

Returns

InMemoryReplayLedger

Methods

claim()

claim(messageId, receivedAt, leaseMs?): Promise<{ claimed: true; reclaimed?: boolean; } | { claimed: false; entry?: ReplayEntry; }>

Atomically claim a message for processing. Returns { claimed: true } when this caller won the claim, { claimed: false, outcome } when the message was already completed, or { claimed: true, reclaimed: true } when a stale lease was reclaimed.

Parameters

messageId

string

receivedAt

number

leaseMs?

number = 30_000

Returns

Promise<{ claimed: true; reclaimed?: boolean; } | { claimed: false; entry?: ReplayEntry; }>

Implementation of

ReplayLedger.claim


complete()

complete(messageId, outcome): Promise<void>

Mark a claimed message as durably processed with its outcome.

Parameters

messageId

string

outcome

ReplayOutcome

Returns

Promise<void>

Implementation of

ReplayLedger.complete


get()

get(messageId): Promise<ReplayEntry | undefined>

Look up a previously processed message.

Parameters

messageId

string

Returns

Promise<ReplayEntry | undefined>

Implementation of

ReplayLedger.get