SqlEventJournal.ts
SqlEventJournal.ts overview
Section titled “SqlEventJournal.ts overview”SQL-backed persistence for the unstable event-log journal.
This module implements EventJournal on top of a SqlClient. It stores event
entries as encoded bytes and stores per-remote sequence metadata in separate
tables, giving event-log programs a durable journal that can be replayed after
restart and synchronized with remote journals.
Since v4.0.0
Exports Grouped by Category
Section titled “Exports Grouped by Category”constructors
Section titled “constructors”Creates an EventJournal backed by a SQL database.
Details
The constructor creates the entry and remote metadata tables when needed,
persists local and remote entries, and uses the configured SqlClient.
Signature
declare const make: (options?: { readonly entryTable?: string readonly remotesTable?: string}) => Effect.Effect<EventJournal.EventJournal["Service"], SqlError.SqlError, SqlClient.SqlClient>Since v4.0.0
layers
Section titled “layers”Provides EventJournal using the SQL-backed implementation created by
make.
When to use
Use when composing a Layer graph that should provide a persistent SQL-backed
EventJournal from an existing SqlClient service.
Details
The layer delegates to make(options), so the same optional entryTable and
remotesTable settings are used and construction requires SqlClient and
may fail with SqlError.
Gotchas
Layer construction performs the same minimal CREATE TABLE IF NOT EXISTS
setup as make; manage indexes and schema migrations outside this layer when
your SQL schema needs more than the built-in tables.
See
makefor constructing the SQL-backed service directlyEventJournal.layerMemoryfor an in-memoryEventJournallayerEventJournal.layerIndexedDbfor an IndexedDB-backedEventJournallayer
Signature
declare const layer: (options?: { readonly entryTable?: string readonly remotesTable?: string}) => Layer.Layer<EventJournal.EventJournal, SqlError.SqlError, SqlClient.SqlClient>Since v4.0.0