Skip to main content

SyncStatus

Struct SyncStatus 

#[non_exhaustive]
pub struct SyncStatus { pub state: EdgeState, pub responder: Option<StoreId>, pub confirmed: Option<SequencePosition>, pub pending: Pending, pub waiting: Waiting, pub far_side: Watermark, pub last_failure: Option<Failure>, }
Expand description

One edge’s status, as of its last step.

Held by the edge and updated by every step, so reading it costs no round trip. #[non_exhaustive], so a field added later does not break a reader. SY-32’s retention gap is not a field: it is read from state by retention_gap, so the two cannot disagree.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§state: EdgeState

Running, parked, or stopped, and why.

§responder: Option<StoreId>

The far side’s store incarnation as this edge knows it: the first responder named by an answer that took effect, or the one Edge::with_responder named. None until then, and for good if the far side never names one (ADR-0104).

An answer naming another store stops the edge (StopCause::Incarnation); this field keeps the pinned store, and the cause names both.

§confirmed: Option<SequencePosition>

The first position of the last local write group the far side acknowledged. Every local event at or below it, and every event of that group, has been acknowledged.

For a single-event append it is the position append returned. A local SequencePosition, meaningful only in the local store: it is the watermark SY-31 says is kept through the projection port, and it is never sent to the far side.

§pending: Pending

How many local events, in write groups above confirmed, are unacknowledged, as of the last step’s read.

Every local event counts, including ones this edge ingested from the far side, which a push hands back and the far side skips.

§waiting: Waiting

What the far side said it still holds past the last pull’s token. Updated only once that pull’s batch has landed locally.

§far_side: Watermark

What the far side last acknowledged holding, per origin store: its Ack::confirmed, a high-water mark per origin rather than a contiguous prefix.

§last_failure: Option<Failure>

The phase and class of the most recent failed step, kept after later steps succeed; None if no step has failed.

Implementations§

§

impl SyncStatus

pub fn is_synced(&self) -> bool

Running, with no local event unconfirmed and the far side saying nothing is waiting, as of the last step.

Examples found in repository?
examples/two-devices-one-seat/src/scenario.rs (line 323)
303    pub async fn sync(&mut self, device: Device) -> Result<Synced, StoryError> {
304        // What landed is counted on central's log before and after: two whole
305        // reads, which a log of six events can afford and a real one would
306        // replace with a count query.
307        let before = self.central.log(Place::Central).await?.len();
308        let (site, handset) = match device {
309            Device::Tablet => (&self.tablet, &mut self.tablet_link),
310            Device::Phone => (&self.phone, &mut self.phone_link),
311        };
312        let mut synced = Synced::default();
313        for _ in 0..MAX_STEPS {
314            let stepped = handset
315                .edge
316                .step(&handset.peer, &site.events)
317                .await
318                .map_err(|source| StoryError::Sync {
319                    device,
320                    source: Box::new(source),
321                })?;
322            synced.pulled = synced.pulled.saturating_add(stepped.ingested.appended);
323            if handset.edge.status().is_synced() {
324                let after = self.central.log(Place::Central).await?.len();
325                synced.landed = after.saturating_sub(before);
326                return Ok(synced);
327            }
328        }
329        Err(StoryError::NotSynced {
330            device,
331            steps: MAX_STEPS,
332        })
333    }

pub const fn retention_gap(&self) -> Option<RetentionGap>

The retention gap that stopped this edge, if one did (SY-32): the far side had forgotten history the edge’s token had not reached.

Derived from state, so the two cannot disagree, and a caller that reads only EdgeState::Stopped still halts.

Trait Implementations§

§

impl Clone for SyncStatus

§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for SyncStatus

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
§

impl Eq for SyncStatus

§

impl PartialEq for SyncStatus

§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
§

impl StructuralPartialEq for SyncStatus

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.