pub struct RangeProgressTracker { /* private fields */ }Expand description
Tracks streaming progress for many ranges over the one physical WAL. A data
member feeds every derived record through index_record
to maintain each range’s primary frontier without splitting the log, and
notes shipped/applied LSNs per range. Every range advances independently, so
one lagging range does not skew another’s lag or failover eligibility.
All updates are monotonic (max): out-of-order or replayed observations
never move a frontier backward.
Implementations§
Source§impl RangeProgressTracker
impl RangeProgressTracker
pub fn new() -> Self
Sourcepub fn index_record(&mut self, record: &ChangeRecord)
pub fn index_record(&mut self, record: &ChangeRecord)
Index one derived record by its range identity, bumping that range’s primary frontier. Records that carry no range identity (legacy / non-range-replicated) are ignored — they belong to no range’s stream.
Sourcepub fn note_streamed(&mut self, range_id: u64, lsn: u64)
pub fn note_streamed(&mut self, range_id: u64, lsn: u64)
Note that records for range_id up to lsn have been shipped to the
follower. Also raises the primary frontier if it lagged behind, since you
cannot stream past what was produced.
Sourcepub fn note_applied(&mut self, range_id: u64, lsn: u64)
pub fn note_applied(&mut self, range_id: u64, lsn: u64)
Note that the follower has durably applied records for range_id up to
lsn. Raises the streamed and primary frontiers if they lagged, since an
applied record was necessarily streamed and produced.
Sourcepub fn observe_position(&mut self, position: &RangeStreamPosition)
pub fn observe_position(&mut self, position: &RangeStreamPosition)
Adopt a follower’s reported position for range_id as the applied
frontier — the inbound counterpart to note_applied
when a follower acks with a RangeStreamPosition.
pub fn progress(&self, range_id: u64) -> Option<&RangeStreamProgress>
Sourcepub fn apply_lag(&self, range_id: u64) -> Option<u64>
pub fn apply_lag(&self, range_id: u64) -> Option<u64>
Apply lag for one range, or None if the range is unknown.
Sourcepub fn iter(&self) -> impl Iterator<Item = &RangeStreamProgress>
pub fn iter(&self) -> impl Iterator<Item = &RangeStreamProgress>
Iterate every tracked range’s progress, ascending by range id.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn failover_eligible(&self, max_lag: u64) -> Vec<u64>
pub fn failover_eligible(&self, max_lag: u64) -> Vec<u64>
The ranges currently within max_lag of their primary frontier —
candidates a later per-range failover decision may promote. Ascending by
range id.
Trait Implementations§
Source§impl Clone for RangeProgressTracker
impl Clone for RangeProgressTracker
Source§fn clone(&self) -> RangeProgressTracker
fn clone(&self) -> RangeProgressTracker
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more