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§
Sourcefn on_event(&mut self, timestamp: i64) -> Option<Watermark>
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.
Sourcefn on_periodic(&mut self) -> Option<Watermark>
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.
Sourcefn current_watermark(&self) -> i64
fn current_watermark(&self) -> i64
Returns the current watermark value without advancing it.
Sourcefn advance_watermark(&mut self, timestamp: i64) -> Option<Watermark>
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.