Keeps a copy of a database (a replica) up to date by sending it only the bytes it is missing. See the README's Replication section.
Keeps a copy of a database (a replica) up to date by sending it only the bytes it is missing. See the README's Replication section.
(can-extend? source state)Returns true when source can extend a replica in state, a replica-state
map, by sending it only the bytes it is missing, and false when the next update
would be a full copy that replaces the replica. This lets an app find out
before syncing that the replica will be replaced, so it can stage the copy
itself: sync into a new database and switch to it.
Returns true when `source` can extend a replica in `state`, a `replica-state` map, by sending it only the bytes it is missing, and false when the next update would be a full copy that replaces the replica. This lets an app find out before syncing that the replica will be replaced, so it can stage the copy itself: sync into a new database and switch to it.
(replica-state xdb)Describes what the replica xdb already has, so a source database can send
it only the bytes it is missing. Returns a map of plain values,
{:committed-size n :checksum c}, which can be sent to the source any way you
like and passed to (io/input-stream source :since state).
A replica whose file is broken, such as one left behind by an interrupted
full copy, has nothing a source could extend, so it is described as empty,
{:committed-size 0 :checksum 0}, and the next sync sends a full copy.
Describes what the replica `xdb` already has, so a source database can send
it only the bytes it is missing. Returns a map of plain values,
`{:committed-size n :checksum c}`, which can be sent to the source any way you
like and passed to `(io/input-stream source :since state)`.
A replica whose file is broken, such as one left behind by an interrupted
full copy, has nothing a source could extend, so it is described as empty,
`{:committed-size 0 :checksum 0}`, and the next sync sends a full copy.(replicate! xdb in)Applies the updates read from in to the replica xdb and commits them.
in is an InputStream of the bytes from (io/input-stream source :since state), such as that stream itself or an HTTP response body carrying it. It
is read to the end but not closed. Returns {:full-copy? b :replica-state s},
where :full-copy? is true when the update replaced the replica with a full
copy and :replica-state is the replica's replica-state right after the
update, read before another sync can change it.
This is (io/copy in (io/output-stream xdb)), except that if reading in
fails, such as when a connection drops, that exception is thrown, with the
output stream's failure to commit the partial update attached as suppressed.
with-open would throw the latter instead. Unless the update had already
arrived in full, the replica stays at its last commit, or, if the update was a
full copy, is left broken until the next sync (see replica-state).
Applies the updates read from `in` to the replica `xdb` and commits them.
`in` is an InputStream of the bytes from `(io/input-stream source :since
state)`, such as that stream itself or an HTTP response body carrying it. It
is read to the end but not closed. Returns `{:full-copy? b :replica-state s}`,
where `:full-copy?` is true when the update replaced the replica with a full
copy and `:replica-state` is the replica's `replica-state` right after the
update, read before another sync can change it.
This is `(io/copy in (io/output-stream xdb))`, except that if reading `in`
fails, such as when a connection drops, that exception is thrown, with the
output stream's failure to commit the partial update attached as suppressed.
`with-open` would throw the latter instead. Unless the update had already
arrived in full, the replica stays at its last commit, or, if the update was a
full copy, is left broken until the next sync (see `replica-state`).cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |