pub struct WatermarkGenerator { /* private fields */ }Expand description
Generates watermarks by tracking the maximum observed event timestamp.
A watermark is emitted at max_event_ts - max_out_of_order_ms after every
advance_threshold events. This provides a balance between latency and
tolerance for out-of-order events.
Implementations§
Source§impl WatermarkGenerator
impl WatermarkGenerator
Sourcepub fn new(max_out_of_order_ms: i64) -> Self
pub fn new(max_out_of_order_ms: i64) -> Self
Create a generator that tolerates up to max_out_of_order_ms of lateness.
Watermarks are emitted every 100 events by default.
Sourcepub fn with_advance_threshold(self, threshold: usize) -> Self
pub fn with_advance_threshold(self, threshold: usize) -> Self
Set the event count after which a watermark is emitted.
Sourcepub fn with_source_id(self, source_id: impl Into<String>) -> Self
pub fn with_source_id(self, source_id: impl Into<String>) -> Self
Set the source identifier embedded in emitted watermarks.
Sourcepub fn observe(&mut self, event_timestamp_ms: i64) -> Option<StreamWatermark>
pub fn observe(&mut self, event_timestamp_ms: i64) -> Option<StreamWatermark>
Observe an event with event_timestamp_ms.
Returns Some(watermark) when the threshold is reached, otherwise None.
Sourcepub fn current_watermark(&self) -> i64
pub fn current_watermark(&self) -> i64
Current watermark timestamp: max_event_ts - max_out_of_order_ms.
Returns i64::MIN before any event has been observed.
Auto Trait Implementations§
impl Freeze for WatermarkGenerator
impl RefUnwindSafe for WatermarkGenerator
impl Send for WatermarkGenerator
impl Sync for WatermarkGenerator
impl Unpin for WatermarkGenerator
impl UnsafeUnpin for WatermarkGenerator
impl UnwindSafe for WatermarkGenerator
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.