Sync / foldkit-sync/journal

editsJournal

function · packages/sync/src/journal.ts:338

function editsJournal<Shared, Principal, Change>(
  options: EditsJournalOptions<Shared, Principal, Change>,
): {
  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.

Recovery starts at the journal's floor, where compaction left it, so a server restarted over a journal that outlived it does not ask 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.