Skip to main content

SyncEngine

Struct SyncEngine 

Source
pub struct SyncEngine<M: RecordMapper> { /* private fields */ }

Implementations§

Source§

impl<M: RecordMapper + 'static> SyncEngine<M>
where M::Item: 'static,

Source

pub fn ledger(&self) -> &Ledger

Source

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.

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).

Source

pub fn note_changed(&mut self, id: &str) -> SyncResult<()>

Offline queue: record that id changed locally. Durable immediately.

Source

pub fn note_deleted(&mut self, id: &str) -> SyncResult<()>

Local deletion: block the id and queue a tombstone write. Durable.

Source

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.

Source

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.

Source

pub fn request_full_replay_once(&mut self, flag: &str)

Replay the whole zone once for flag (one-shot repair migrations).

Source

pub fn run_pass(&mut self) -> PassReport

Runs one sync pass and records it in SyncEngine::metrics.

Source

pub fn status(&self) -> SyncStatus

Pass counters, ledger queue sizes and process resource usage, read now. No polling thread runs for this.

Source

pub fn metrics(&self) -> SyncMetrics

Cumulative pass counters and current ledger queue sizes.

Auto Trait Implementations§

§

impl<M> !RefUnwindSafe for SyncEngine<M>

§

impl<M> !UnwindSafe for SyncEngine<M>

§

impl<M> Forget for SyncEngine<M>

§

impl<M> Freeze for SyncEngine<M>

§

impl<M> Move for SyncEngine<M>

§

impl<M> Send for SyncEngine<M>
where Arc<M>: Send, Arc<dyn LocalStore<<M as RecordMapper>::Item>>: Send, Box<dyn ConflictPolicy<<M as RecordMapper>::Item>>: Send,

§

impl<M> Sync for SyncEngine<M>
where Arc<M>: Sync, Arc<dyn LocalStore<<M as RecordMapper>::Item>>: Sync, Box<dyn ConflictPolicy<<M as RecordMapper>::Item>>: Sync,

§

impl<M> Unpin for SyncEngine<M>
where Arc<M>: Unpin, Arc<dyn LocalStore<<M as RecordMapper>::Item>>: Unpin, Box<dyn ConflictPolicy<<M as RecordMapper>::Item>>: Unpin,

§

impl<M> UnsafeUnpin for SyncEngine<M>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.