Skip to main content

Module sync

Module sync 

Source
Expand description

Synchronization traits: the read/write faces of a replica and the cursors they exchange.

  • LogProcessor — write side: apply an entry at (peer, index). Multi-writer, idempotent.
  • LogSource — read side: read_since to pull, cursors / watch_cursors to publish progress.

A store that is both is a Replica (the SQL oplog). A file log reads any origin but writes only its own (FileLogSink), so it’s a FileLogReplica — the type-level form of “only the originating device writes its own log”. Both faces speak PeerCursors, a per-origin version vector. The convergence drivers that consume these traits come later.

Structs§

Applied
Outcome of LogProcessor::apply.

Enums§

CursorsEvent
An event from watch_cursors.
SyncError
The sync subsystem’s error: reading a log (LogSource), applying entries (LogProcessor), or writing the local log (FileLogSink). Backends erase their own errors into SyncError::Backend, so the object-safe traits share one fixed error type instead of an associated one.

Traits§

FileLogPuller
Synchronous reader over the segment directories — one per origin. Sync because it decodes local files; an adapter pairs it with a watch/poll loop to present it as an async LogSource.
FileLogReplica
A file log as a replica: multi-reader (LogSource), single-writer (FileLogSink). The single-writer counterpart to Replica; owned by its mirror, not shared.
FileLogSink
Write side of a file log: append to your own origin only. No method writes a foreign origin — that’s the single-writer invariant. The caller supplies each entry’s index (the oplog assigns them; the file log follows).
HasCursors
Snapshot or watch a replica’s cursor vector — the shared base of LogProcessor and LogSource.
LogProcessor
The apply target of replication: absorbs entries addressed by (peer, index).
LogSource
The pull side of replication: publish progress as cursors, hand back entries past a position.
Replica
A full replica: readable (LogSource) and writable for any origin (LogProcessor). The SQL oplog is this, so one type serves, relays, and merges. Contrast FileLogReplica, which writes only its own origin.

Type Aliases§

CursorStream
Stream from watch_cursors; ending means the watch closed.
PeerCursors
Per-origin position: peer id → next entry index. The value for a peer is what to pass read_since for the next entry; an absent key means 0.