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
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.state: EdgeStateRunning, 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: PendingHow 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: WaitingWhat 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: WatermarkWhat 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
impl SyncStatus
pub fn is_synced(&self) -> bool
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?
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>
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.