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 | |
journalChangesScoped | Scope-managed version of journalChanges: forks the document commit listener into the caller's Scope via Effect.forkScoped so cleanup is automatic when the… |
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).… |
reaction | Declares a reaction of a contract from Sync.forApplication(App).make: after each committed Message in on, in journal order, run is called once at least, and… |
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… |
serverJournal | The server's side of one document: appendAsServer, and the declared reactions with what runs them. Registers each reaction's cursor at the journal's current… |
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 | |
HostDefect | A document host broke on its own side: the upgrade was answered 500 "Internal error", the socket closed with 1011, or a notice went unsent. The replica is… |
HostSocket | A server socket a host serves on: Sync's socket, and a close with a code the replica reads. |
JournalExchangeOptions | |
Parked | A run set aside: it failed for good, or too often. Its reaction went on without it. |
Reaction | One declared reaction of one document: what it runs on, what it may append, and what its handler needs. Made by reaction, given to serverJournal. |
ReactionOptions | |
ServerJournal | |
ServerJournalOptions | |
Trigger | A committed operation, as a reaction is given it. |
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… |
HostStage | Where a document host broke. |
Requires | The services a list of reactions needs: none for none. |