Durable per-run event sequences with idempotent event ids and payload fencing.

Implements

Constructors

Methods

  • One transaction: the run's anchor row is locked (so sequence numbers of one run are handed out one at a time and the fence is read under the same lock), a repeated event id answers its existing sequence, the row is written with the run's next number and the counter advances; behind the fence a content event is written without its payload. Ids are unique across runs, and two runs' anchors do not order their appends: an append whose id another run's append writes and commits while this one waits on the index writes nothing and answers that event's sequence, as a repeated id does.

    Parameters

    Returns Promise<{
        inserted: boolean;
        seq: number;
    }>