Sync / API
foldkit-sync/journal
foldkit-sync/journal — the server's side of an exchange, over a
foldkit-durable journal. Every Sync server needs the same loop: append
what a replica sends, refuse what cannot be taken, and read back what
committed since the replica's cursor. Written by hand three times, it
failed the same way: an operation that did not decode failed the whole
exchange, so the replica sent it again on every one and the edits behind it
never went. Here, refused operations are reported by id, and the replica
drops them.
Functions
documentHost | One document's Sync host, for any runtime that upgrades a request to a socket: a Durable Object (foldkit-sync/do), or Node's ws. Each upgrade is answered… |
editsJournal | 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… |
journalChanges | Calls listener each time the document commits, for Sync.transport.serve's changes, so a socket wakes its replica to exchange. Returns the unsubscribe. |
journalExchange | One replica's exchanges with the journal, as the replica's transport speaks them (Sync.transport.fromPromise, or behind Sync.transport.serve on a socket).… |
serveJournal | Serves one accepted socket over the journal: each exchange frame answered by journalExchange with the connection's principal, and a notice sent after each… |
Classes
TableAheadOfJournalError | The table holds revisions past every sequence the journal has: it outlived a reset of the journal, or was built from another. New edits commit at sequences… |
Interfaces
Accepted | An upgrade documentHost accepted. Exactly one of the two must follow: serve once the runtime has opened the socket, or abandon when it never will (the… |
DocumentHostOptions | What documentHost needs: one document, who may open it, and what they may do. |
EditsJournalOptions | |
HostSocket | A server socket a host serves on: Sync's socket, and a close with a code the replica reads. |
JournalExchangeOptions | |
Types
DocumentHostOptionsLayer | What the resolver needs (a session store), required exactly when it needs something. Built per upgrade and kept until the socket closes, since revalidate… |