Skip to main content

Module document_sync

Module document_sync 

Source
Expand description

Which records a device is sent when it joins a workspace, and which it asks for when it needs them.

Most records are eager: a joining device is replayed them and follows their changes live. A record can instead be declared on-demand by its id: a joining device is not replayed it, and gets its history and its live changes only once it asks to open it. A big workspace keeps the documents nobody has open out of every join that way.

A record that grows without end is kept as a chain of numbered parts instead, each a record of its own: derived:part.<n>@<base>. The part with the highest number a host holds is the chain’s head, which takes the new writes and is replayed like an eager record; every earlier part is on-demand. A part’s id is its base and its number, so two writers that both start part n + 1 start the same record, and nothing has to decide which of them did.

A record the platform splits into chunks keeps one of them — chunk 0, the record itself — eager and declares the rest (derived:chunk.<n>@<base>, n from 1) on-demand: the record’s manifest says which chunks exist, and a device is sent the ones it opens. A write therefore moves only the chunk it changed to the devices holding it.

The declaration is the record id itself, because every host can read the route a change travels on, sealed or not.

A workspace can also send all of its records on demand: a public one, which anyone may walk into, replays a newcomer only its governance and its shared desktop, whatever its records’ ids say. Its host decides that for the workspace and says so in the Ready that ends a device’s replay; the device then asks for every record it opens, and takes one as new only once the host answered it holds none of it.

A device that holds no part of a chain finds its head by opening the chain’s head (derived:head@<base>, chain_head): a name for whichever part is the head, which holds nothing of its own. The host sends the head part’s history in answer, and the device follows the chain from then on, each later head included: one round trip, whichever part the head is. Answered with nothing, the chain has no part yet.

Enums§

DocumentSync
How a record reaches the devices of a workspace.

Functions§

chain_head
The id of the head of the chained record base: opening it sends the chain’s newest part, whichever that is, and follows the chain.
document_chunk
The id of chunk number of the split record base (number from 1; chunk 0 is base).
document_part
The id of part index of the chained record base.
document_sync
How record (a route’s record id) is synced.
on_demand_document
The id of base declared on-demand.