Skip to content

Journal

Defined in: src/persistence/Journal.ts:10

Pluggable event journal — the persistence-plugin boundary. Core ships with an in-memory reference implementation and a SQLite-based one; the interface is deliberately narrow so third-party plug-ins (Cassandra, ScyllaDB, Postgres, …) only have to implement four methods.

readonly optional events?: JournalEventBus

Defined in: src/persistence/Journal.ts:51

Optional in-process notification bus. When present, the read-side query layer subscribes here for sub-poll-interval push delivery (see JournalEventBus). Journals that span processes (Cassandra, Postgres) leave it undefined — the query layer falls back to the polling loop.

append<E>(pid, events, expectedSeq, tags?): Promise<PersistentEvent<E>[]>

Defined in: src/persistence/Journal.ts:17

Append events to the stream of pid, enforcing optimistic concurrency: the current highest sequence number MUST equal expectedSeq or the call throws JournalConcurrencyError. Returns the written events with their assigned sequence numbers.

E = unknown

string

readonly E[]

number

readonly string[]

Promise<PersistentEvent<E>[]>


optional close(): Promise<void>

Defined in: src/persistence/Journal.ts:54

Best-effort teardown; idempotent.

Promise<void>


delete(pid, toSeq): Promise<void>

Defined in: src/persistence/Journal.ts:39

Delete events up to and including toSeq — used when compacting past a snapshot.

string

number

Promise<void>


highestSeq(pid): Promise<number>

Defined in: src/persistence/Journal.ts:36

Current highest sequence number for pid — 0 if no events exist.

string

Promise<number>


persistenceIds(): Promise<string[]>

Defined in: src/persistence/Journal.ts:42

Persistence IDs currently known to the journal (useful for projections).

Promise<string[]>


read<E>(pid, fromSeq, toSeq?): Promise<PersistentEvent<E>[]>

Defined in: src/persistence/Journal.ts:29

Return events in (fromSeq, …, toSeq] order. toSeq defaults to the current highest sequence number. Inclusive bounds — fromSeq is the first event returned, not the “after” cursor.

E = unknown

string

number

number

Promise<PersistentEvent<E>[]>