pub struct PartitionTracker { /* private fields */ }Expand description
Contiguity tracker for one partition within one assignment epoch.
Sequence numbers start at 0 and must be registered contiguously; a gap is a driver bug and panics. Resolutions arrive out of order (sharded sinks ack whenever their flushes complete).
use etl_core::checkpoint::{AckStatus, PartitionTracker};
let mut t = PartitionTracker::new();
t.register(0, 99); // batch 0 covers offsets ..=99
t.register(1, 199);
let _ = t.resolve(1, AckStatus::Delivered); // out of order
assert_eq!(t.advance(), None); // batch 0 still pending
let _ = t.resolve(0, AckStatus::Delivered);
assert_eq!(t.advance(), Some(200)); // committable positionImplementations§
Source§impl PartitionTracker
impl PartitionTracker
Sourcepub fn new() -> PartitionTracker
pub fn new() -> PartitionTracker
A fresh tracker expecting its first registration at sequence 0.
Sourcepub fn register(&mut self, seq: u64, last_offset: i64)
pub fn register(&mut self, seq: u64, last_offset: i64)
Register a newly issued batch. Sequences must be contiguous.
Registering after a stall is legal (batches already in flight when the failure surfaced still arrive); they will never advance the watermark.
§Panics
Panics on a sequence gap — the driver issued batches out of order, which would silently corrupt watermark accounting.
Sourcepub fn resolve(&mut self, seq: u64, status: AckStatus) -> ResolveOutcome
pub fn resolve(&mut self, seq: u64, status: AckStatus) -> ResolveOutcome
Apply one resolution. Out-of-order and cross-batch interleavings are
expected; duplicates and unknown sequences are reported (and
debug_asserted) rather than corrupting state.
Sourcepub fn advance(&mut self) -> Option<i64>
pub fn advance(&mut self) -> Option<i64>
Pop the contiguous delivered prefix and return the new committable
offset (one past the last delivered batch), or None if the
watermark did not move.
If the batch at the head has failed, the tracker stalls permanently: everything delivered before the failure is still reported (commit up to the failure is correct), but nothing past it ever will be.
Sourcepub fn stalled(&self) -> bool
pub fn stalled(&self) -> bool
Whether a failed batch has reached the head and blocked the watermark. Permanent once set.
Sourcepub fn stalled_since(&self) -> Option<Instant>
pub fn stalled_since(&self) -> Option<Instant>
When the stall was first observed, for watermark-age alerting.
Sourcepub fn stalled_seq(&self) -> Option<u64>
pub fn stalled_seq(&self) -> Option<u64>
Sequence number of the failed batch that caused the stall.
Trait Implementations§
Source§impl Debug for PartitionTracker
impl Debug for PartitionTracker
Source§impl Default for PartitionTracker
impl Default for PartitionTracker
Source§fn default() -> PartitionTracker
fn default() -> PartitionTracker
Auto Trait Implementations§
impl Freeze for PartitionTracker
impl RefUnwindSafe for PartitionTracker
impl Send for PartitionTracker
impl Sync for PartitionTracker
impl Unpin for PartitionTracker
impl UnsafeUnpin for PartitionTracker
impl UnwindSafe for PartitionTracker
Blanket Implementations§
§impl<U> As for U
impl<U> As for U
§fn as_<T>(self) -> Twhere
T: CastFrom<U>,
fn as_<T>(self) -> Twhere
T: CastFrom<U>,
self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. Read more