Sync / foldkit-sync/journal
editsJournal
function · packages/sync/src/journal.ts:662
function editsJournal<Shared, Principal, Change, Absorbed = never>(
options: EditsJournalOptions<Shared, Principal, Change, Absorbed>,
): {
readonly settle: Effect.Effect<void, unknown>
readonly absorb: Effect.Effect<void, unknown>
}The table as the journal's read model: settle applies each committed
edit through apply, as a recovery intent, and absorb records in the
journal what the table holds and compacts the log behind it. For
journalExchange's settle, and a clock that absorbs.
How far the table holds is a cursor the journal stores (journal.cursors),
started at the journal's floor, where compaction left it, so a server
restarted over a journal that outlived it neither walks the log again nor
asks for history that is gone. Intents are keyed by the journal's epoch as
well as the operation, so after a reset an operation sent again is applied
again, not taken as already run.