跳转到内容
简体中文

CassandraJournalOptionsType

此内容尚不支持你的语言。

Defined in: src/persistence/journals/CassandraJournalOptions.ts:5

readonly optional allIdsTable?: string

Defined in: src/persistence/journals/CassandraJournalOptions.ts:11

Lookup table for persistenceIds(). Default: all_persistence_ids.


readonly optional autoCreateKeyspace?: boolean

Defined in: src/persistence/journals/CassandraClient.ts:44

If true, create the keyspace on startup (simple strategy, rf=1). Dev-friendly default.

CassandraConnection.autoCreateKeyspace


readonly optional autoCreateTables?: boolean

Defined in: src/persistence/journals/CassandraJournalOptions.ts:21

Auto-create the events/metadata/all-ids tables on first connect.


readonly optional client?: CassandraClientLike

Defined in: src/persistence/journals/CassandraJournalOptions.ts:86

Inject a pre-built client instead of letting the journal instantiate cassandra-driver itself — useful for tests and when the host already owns the client lifecycle.


readonly optional consistency?: number

Defined in: src/persistence/journals/CassandraClient.ts:57

CQL consistency level to use for all reads and writes. Default: LOCAL_QUORUM (value 6 in the driver). Pass the numeric value from cassandra-driver’s types.consistencies.

CassandraConnection.consistency


readonly contactPoints: readonly string[]

Defined in: src/persistence/journals/CassandraClient.ts:34

Node(s) to seed the cluster topology from.

CassandraConnection.contactPoints


readonly optional credentials?: object

Defined in: src/persistence/journals/CassandraClient.ts:40

Optional username/password for PLAIN auth.

password: string

username: string

CassandraConnection.credentials


readonly optional eventsTable?: string

Defined in: src/persistence/journals/CassandraJournalOptions.ts:7

Table name for events. Default: events.


readonly keyspace: string

Defined in: src/persistence/journals/CassandraClient.ts:38

Keyspace to USE after connect. Must already exist, or pass autoCreateKeyspace: true.

CassandraConnection.keyspace


readonly optional lightweightTransactions?: boolean

Defined in: src/persistence/journals/CassandraJournalOptions.ts:65

Serialize concurrent appends with a Cassandra lightweight transaction (Paxos) that claims the sequence range on the metadata row before any event is written (#475). Default: true.

Without it the append path is a plain read-modify-write: two writers that both read head N both pass the expectedSeq check and both INSERT at sequence_nr = N+1. A Cassandra INSERT is an upsert, so the later write silently overwrites the earlier one and both callers are told their event was persisted. The relational backends can’t lose that race — their primary key rejects the loser — so the LWT is what gives Cassandra the same JournalConcurrencyError contract.

The cost is one Paxos round-trip per append, not per event: the claim is a single conditional statement on the metadata row, while the events themselves still go out in the same unlogged per-partition batch. Turn it off only if you genuinely guarantee a single writer per persistence id and want that round-trip back — a losing concurrent append then loses its event with no error.


readonly optional localDataCenter?: string

Defined in: src/persistence/journals/CassandraClient.ts:36

Local DC — required for DCAwareRoundRobinPolicy. Defaults to datacenter1.

CassandraConnection.localDataCenter


readonly optional metadataTable?: string

Defined in: src/persistence/journals/CassandraJournalOptions.ts:9

Table tracking the highest sequence number per pid. Default: metadata.


readonly optional partitionSize?: number

Defined in: src/persistence/journals/CassandraJournalOptions.ts:19

Rows per partition before rolling over to a new one. Keeps Cassandra partitions bounded. Default: 500_000 — a good balance between write amplification and read-scan cost for long-lived streams.


readonly optional port?: number

Defined in: src/persistence/journals/CassandraClient.ts:42

Port — defaults to 9042.

CassandraConnection.port


readonly optional replication?: object

Defined in: src/persistence/journals/CassandraClient.ts:46

Replication options used by autoCreateKeyspace. Ignored otherwise.

readonly optional class?: "SimpleStrategy" | "NetworkTopologyStrategy"

readonly optional dataCenters?: Readonly<Record<string, number>>

For NetworkTopologyStrategy, map of DC → replication factor.

readonly optional replicationFactor?: number

CassandraConnection.replication


readonly optional serialConsistency?: number

Defined in: src/persistence/journals/CassandraJournalOptions.ts:80

Serial consistency for the LWT claim’s Paxos phase. Ignored when lightweightTransactions is off. Pass the numeric value from cassandra-driver’s types.consistencieslocalSerial (9) or serial (8).

Left unset the driver picks cluster-wide SERIAL, which needs a quorum of replicas across every datacenter — so on a multi-DC keyspace each append pays a cross-DC round-trip, quietly undoing the local-DC-only write path that consistency: LOCAL_QUORUM buys. Set localSerial (9) to keep Paxos inside the local DC, at the cost of losing linearizability against writers in another DC (fine when a pid is only ever written from one DC — the usual sharding layout).


readonly optional serializer?: Serializer<unknown>

Defined in: src/persistence/storage/StoreSerializerOptions.ts:23

Custom payload serializer. When set, the store writes rows in the self-describing __serialized__ framing (see PayloadCodec) instead of the default tagged JSON; rows of both formats can coexist in one stream, but reading a framed row back requires a serializer with the same id to be configured.

StoreSerializerOptionsBase.serializer


readonly optional tagIndexTable?: string

Defined in: src/persistence/journals/CassandraJournalOptions.ts:13

Tag-index side table populated when useTagIndex is set. Default: events_by_tag.


readonly optional useTagIndex?: boolean

Defined in: src/persistence/journals/CassandraJournalOptions.ts:44

Opt in to maintaining an events_by_tag side table for indexed eventsByTag queries (#44). When set, every append writes one extra row per (event, tag) pair to the side table inside the same batch as the primary events insert; CassandraQuery.currentEventsBy Tag then walks a single tag-partition instead of scanning the whole journal client-side.

Off by default to keep existing schemas compatible — operators opting in must run the side-table DDL on their cluster (the journal issues CREATE TABLE IF NOT EXISTS when autoCreateTables is also true; otherwise the DDL in CassandraClient.tagIndexDdl can be applied manually).

Caveat: delete(toSeq) does NOT propagate to the side table — deleting from events_by_tag would require either a secondary index on persistence_id or pre-reading the event’s tags (extra round-trips on the hot path). Operators with delete-heavy workloads should rely on Cassandra TTLs or accept stale tag entries (queries dedupe via the primary key, so they’re harmless — just storage overhead).