Skip to content

CassandraJournal

Defined in: src/persistence/journals/CassandraJournal.ts:85

Journal backed by Apache Cassandra or ScyllaDB — same CQL protocol, one plug-in serves both. Schema:

  • composite partition key (persistence_id, partition_nr) — keeps individual partitions bounded even for long-lived event streams;
  • clustering column sequence_nr for in-stream ordering;
  • a small metadata row per persistence_id tracking max_sequence_nr.

The journal relies on a single writer per persistence id — the standard PersistentActor contract, one instance per id at a time. Under that assumption the “read max-seq → append → write max-seq” sequence is safe without server-side LWT. If you need multi-writer safety, wrap the metadata update in an LWT (IF max_sequence_nr = ?).

new CassandraJournal(options): CassandraJournal

Defined in: src/persistence/journals/CassandraJournal.ts:95

CassandraJournalOptions

CassandraJournal

get tagIndexTable(): string

Defined in: src/persistence/journals/CassandraJournal.ts:293

Side-table name used when useTagIndex is set — visible so CassandraQuery can target it directly.

string


get useTagIndex(): boolean

Defined in: src/persistence/journals/CassandraJournal.ts:295

Whether dual-writes to the tag-index side table are enabled.

boolean

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

Defined in: src/persistence/journals/CassandraJournal.ts:117

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

string

readonly E[]

number

readonly string[]

Promise<PersistentEvent<E>[]>

Journal.append


close(): Promise<void>

Defined in: src/persistence/journals/CassandraJournal.ts:278

Best-effort teardown; idempotent.

Promise<void>

Journal.close


delete(pid, toSeq): Promise<void>

Defined in: src/persistence/journals/CassandraJournal.ts:251

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

string

number

Promise<void>

Journal.delete


highestSeq(pid): Promise<number>

Defined in: src/persistence/journals/CassandraJournal.ts:246

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

string

Promise<number>

Journal.highestSeq


persistenceIds(): Promise<string[]>

Defined in: src/persistence/journals/CassandraJournal.ts:268

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

Promise<string[]>

Journal.persistenceIds


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

Defined in: src/persistence/journals/CassandraJournal.ts:214

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

string

number

number

Promise<PersistentEvent<E>[]>

Journal.read


start(): Promise<void>

Defined in: src/persistence/journals/CassandraJournal.ts:102

Explicitly connect + ensure schema. Called lazily on first use.

Promise<void>