# HG changeset patch # User drewp@bigasterisk.com # Date 2024-06-04 06:01:54 # Node ID a4052905ca7d769314272f1fdcda518f14e4e11d # Parent 4bab5bbce195e68383baa049ed6ea8ca9dc23e4b notes about how rdfdb syncs, or should sync diff --git a/doc/graph-sharing.svg b/doc/graph-sharing.svg new file mode 100644 --- /dev/null +++ b/doc/graph-sharing.svg @@ -0,0 +1,782 @@ + + + + + + + + + + <graph> element with access to the window's SyncedGraph and a little status widget + + <some-page-or-subpage> + rdfdb server + ws:/syncedGraph2024 + ← graph changed- deletes- adds- fromVersion (0 for resync)- toVersion + ⇄ 2024 protocol (avro) + graph.patch(p) +immediately patches local side, storing the accumulated patch from the last known graph version + + → graph edit- fromVersion- deletes- adds + graph.sync() +"send our diffs, and make our local graph match the rdfdb one" +Called after patch, reconnect, etc. + stores and syncs with disk: +- stmts +- graphVersion + +and optionally some recent versions that clients might refererence in their edits, to reduce resyncs + browser window + one window-scoped SyncedGraph object + graph.onVersionChangedif we are based on the fromVersion + Internally, the graph is stored as +- a local patch on top of +- an rdfdb graph @ graphVersion + + + + + ws:/syncedGraph (legacy) + sends full graph at startup,accepts patches,broadcasts them to other clients,disconnects on detected conflicts + + ⇄ patches protocol (JSON) + + ⇄ sub/unsub protocol (db_protocol.ts) + ← patch +(1st few patches contain the whole graph) + +→ patch + +Upon conflict, server disconnects + + + Not implemented + +clients sub and unsub from stmt patterns; server sends sub events + + + + + other <graph> elements share the same state + + edit(from=v1,-stmt1,+stmt2, to=proposedVx) + edit(from=v1,-stmt1,+stmt3) + graphVersion + + + v1 + + + + v2 + + + + v3 + + + + v4 + + clientC1 + clientC2 + err, C2 needs to be brought up to date with v2 then it can retry. C2 keeps its local patch for now + changed(..., from=v1, to=v2, aka 'proposedVx') + ok + rdfdb + C1 learns that proposedVx is now v2 +C2 forgot what v1 has, and keeps its local patch. +Neither C1 (knew v2) nor C2 (forgot v1) cares about the contents of this patch! C2 would have, if it remembered v1. + sendMe(v0 to v2) + edit(from=v0, to=v2) + this goes to C2 only + +