pub struct SyncEngine<M: RecordMapper> { /* private fields */ }Implementations§
Source§impl<M: RecordMapper + 'static> SyncEngine<M>where
M::Item: 'static,
impl<M: RecordMapper + 'static> SyncEngine<M>where
M::Item: 'static,
pub fn ledger(&self) -> &Ledger
Sourcepub fn consent_request(&self) -> Option<ConsentRequest>
pub fn consent_request(&self) -> Option<ConsentRequest>
The scope change currently awaiting consent, if any. Durable: it survives a restart and
is also reported by PassOutcome::ConsentRequired.
Sourcepub fn grant_consent(
&mut self,
to: &str,
choice: ConsentChoice,
) -> SyncResult<()>
pub fn grant_consent( &mut self, to: &str, choice: ConsentChoice, ) -> SyncResult<()>
Record explicit consent to sync into the new account to (the to of the pending
ConsentRequest). Resets the ledger for the new scope (the old account’s cursor,
versions and queued deletions never reach it) and lets the next pass run. Refused when
nothing is pending, when to is not the pending target, or when the signed-in scope has
since moved on (the next pass then raises a fresh request).
Sourcepub fn note_changed(&mut self, id: &str) -> SyncResult<()>
pub fn note_changed(&mut self, id: &str) -> SyncResult<()>
Offline queue: record that id changed locally. Durable immediately.
Sourcepub fn note_deleted(&mut self, id: &str) -> SyncResult<()>
pub fn note_deleted(&mut self, id: &str) -> SyncResult<()>
Local deletion: block the id and queue a tombstone write. Durable.
Sourcepub fn note_deleted_many(
&mut self,
ids: &[String],
unconfirmed: &BTreeSet<String>,
) -> SyncResult<usize>
pub fn note_deleted_many( &mut self, ids: &[String], unconfirmed: &BTreeSet<String>, ) -> SyncResult<usize>
SyncEngine::note_deleted for many ids with one durable ledger write. The ledger is
serialized and replaced in full on every write, so a caller with many deletions must not
call note_deleted in a loop. Nothing is written when no id is queued.
An id is in one of three states: (a) not buried; (b) buried and confirmed (in
tombstones, not in pending_tombstones: the remote already holds the deletion); (c)
buried and pending. A state (b) id is a no-op: it is not queued again and its tombstone
value is not rewritten, so a later withdrawal can never lift a confirmed deletion. The one
exception is an id in unconfirmed, which the caller cannot vouch the remote holds (a
tombstone kept after its queued write was withdrawn without proof); it is queued again.
An id that already has a tombstone keeps that tombstone’s value; only an id with none is
buried (now). Returns how many ids were queued.
Sourcepub fn withdraw_pending_tombstones(
&mut self,
lift: &[String],
keep: &[String],
) -> SyncResult<usize>
pub fn withdraw_pending_tombstones( &mut self, lift: &[String], keep: &[String], ) -> SyncResult<usize>
Withdraw queued tombstones the caller can no longer vouch for. Every id of lift and
keep that is in pending_tombstones leaves the queue, so it is not written to the
zone. lift names ids whose tombstone the caller proves it created (no tombstone existed
before it queued them): that local tombstone is lifted with the queue entry, so the stale
deletion neither reaches the remote nor keeps suppressing the record. keep names every
other queued id (prior state unknown): its tombstone stays, so local suppression is not
lifted; an id in both lists is kept. Ids that are not queued are left alone: a tombstone
the remote already acknowledged (in tombstones, not in pending_tombstones) is never
touched, so a confirmed deletion survives a requeue followed by a withdrawal. One durable
ledger write; nothing is written when no id is queued. Returns how many ids left the
queue. A failed write rolls the change back.
Sourcepub fn request_full_replay_once(&mut self, flag: &str)
pub fn request_full_replay_once(&mut self, flag: &str)
Replay the whole zone once for flag (one-shot repair migrations).
Sourcepub fn run_pass(&mut self) -> PassReport
pub fn run_pass(&mut self) -> PassReport
Runs one sync pass and records it in SyncEngine::metrics.
Sourcepub fn status(&self) -> SyncStatus
pub fn status(&self) -> SyncStatus
Pass counters, ledger queue sizes and process resource usage, read now. No polling thread runs for this.
Sourcepub fn metrics(&self) -> SyncMetrics
pub fn metrics(&self) -> SyncMetrics
Cumulative pass counters and current ledger queue sizes.