Skip to main content

WatermarkGenerator

Trait WatermarkGenerator 

Source
pub trait WatermarkGenerator: Send {
    // Required methods
    fn on_event(&mut self, timestamp: i64) -> Option<Watermark>;
    fn on_periodic(&mut self) -> Option<Watermark>;
    fn current_watermark(&self) -> i64;
    fn advance_watermark(&mut self, timestamp: i64) -> Option<Watermark>;
}
Expand description

Trait for generating watermarks from event timestamps.

Implementations track observed timestamps and produce watermarks that indicate event-time progress. The watermark is an assertion that no events with timestamps earlier than the watermark are expected.

Required Methods§

Source

fn on_event(&mut self, timestamp: i64) -> Option<Watermark>

Process an event timestamp and potentially emit a new watermark.

Called for each event processed. Returns Some(watermark) if the watermark should advance, None otherwise.

Source

fn on_periodic(&mut self) -> Option<Watermark>

Called periodically to emit watermarks based on wall-clock time.

Useful for generating watermarks even when no events are arriving.

Source

fn current_watermark(&self) -> i64

Returns the current watermark value without advancing it.

Source

fn advance_watermark(&mut self, timestamp: i64) -> Option<Watermark>

Advances the watermark to at least the given timestamp from an external source.

Called when the source provides an explicit watermark (e.g., Source::watermark()). Returns Some(Watermark) if the watermark advanced, None if the timestamp was not higher than the current watermark.

Implementors§