Sync / foldkit-sync/journal
journalExchange
function · packages/sync/src/journal.ts:101
function journalExchange<Message, Shared, Principal>(
options: JournalExchangeOptions<Message, Shared, Principal>,
): TransportClientOne replica's exchanges with the journal, as the replica's transport
speaks them (Sync.transport.fromPromise, or behind
Sync.transport.serve on a socket). Each pending operation is appended in
order, and acknowledged once committed, or already committed. One is
rejected by its id when its message does not decode, it names another
document, or the journal refuses it (authorize, validate); the replica
drops it rather than send it again. Only an entry with no id at all, a
cursor ahead of the journal's, a connection opens refuses, or admit or
the journal failing fails the exchange. The reply carries what committed
after the replica's cursor, a checkpoint when that history was compacted,
and the journal's epoch, so a replica of a reset journal starts again.