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.
Properties
Section titled “Properties”events?
Section titled “events?”
readonlyoptionalevents?: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.
Methods
Section titled “Methods”append()
Section titled “append()”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.
Type Parameters
Section titled “Type Parameters”E = unknown
Parameters
Section titled “Parameters”string
events
Section titled “events”readonly E[]
expectedSeq
Section titled “expectedSeq”number
readonly string[]
Returns
Section titled “Returns”Promise<PersistentEvent<E>[]>
close()?
Section titled “close()?”
optionalclose():Promise<void>
Defined in: src/persistence/Journal.ts:54
Best-effort teardown; idempotent.
Returns
Section titled “Returns”Promise<void>
delete()
Section titled “delete()”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.
Parameters
Section titled “Parameters”string
number
Returns
Section titled “Returns”Promise<void>
highestSeq()
Section titled “highestSeq()”highestSeq(
pid):Promise<number>
Defined in: src/persistence/Journal.ts:36
Current highest sequence number for pid — 0 if no events exist.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<number>
persistenceIds()
Section titled “persistenceIds()”persistenceIds():
Promise<string[]>
Defined in: src/persistence/Journal.ts:42
Persistence IDs currently known to the journal (useful for projections).
Returns
Section titled “Returns”Promise<string[]>
read()
Section titled “read()”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.
Type Parameters
Section titled “Type Parameters”E = unknown
Parameters
Section titled “Parameters”string
fromSeq
Section titled “fromSeq”number
toSeq?
Section titled “toSeq?”number
Returns
Section titled “Returns”Promise<PersistentEvent<E>[]>