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() -> RangeProgressTracker
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 moreSource§impl Debug for RangeProgressTracker
impl Debug for RangeProgressTracker
Source§impl Default for RangeProgressTracker
impl Default for RangeProgressTracker
Source§fn default() -> RangeProgressTracker
fn default() -> RangeProgressTracker
Auto Trait Implementations§
impl Forget for RangeProgressTracker
impl Freeze for RangeProgressTrackerwhere
*const LeafNode<u64, RangeStreamProgress> is !null: Freeze,
PhantomData<(Owned, LeafOrInternal)>: Freeze,
PhantomData<Box<(u64, RangeStreamProgress)>>: Freeze,
impl Move for RangeProgressTracker
impl RefUnwindSafe for RangeProgressTracker
impl Send for RangeProgressTrackerwhere
NodeRef<Owned, u64, RangeStreamProgress, LeafOrInternal>: Send,
BoxRaw<(u64, RangeStreamProgress)>: Send,
impl Sync for RangeProgressTrackerwhere
NodeRef<Owned, u64, RangeStreamProgress, LeafOrInternal>: Sync,
BoxRaw<(u64, RangeStreamProgress)>: Sync,
impl Unpin for RangeProgressTrackerwhere
*const LeafNode<u64, RangeStreamProgress> is !null: Unpin,
Box<(u64, RangeStreamProgress)>: Unpin,
impl UnsafeUnpin for RangeProgressTrackerwhere
*const LeafNode<u64, RangeStreamProgress> is !null: UnsafeUnpin,
PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin,
PhantomData<Box<(u64, RangeStreamProgress)>>: UnsafeUnpin,
impl UnwindSafe for RangeProgressTracker
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request