WatermarkGenerator

Trait WatermarkGenerator 

Source
pub trait WatermarkGenerator:
    Send
    + Sync
    + Debug
    + 'static {
    // Required methods
    fn on_event(&mut self, timestamp: DateTime<Utc>) -> Option<Watermark>;
    fn on_periodic_emit(&mut self) -> Option<Watermark>;
    fn current_watermark(&self) -> Watermark;

    // Provided method
    fn on_end_of_stream(&mut self) -> Watermark { ... }
}
Expand description

Trait for generating watermarks from observed event timestamps.

Different strategies exist for watermark generation:

  • Monotonic: watermark follows the maximum observed timestamp exactly
  • Bounded out-of-orderness: allows for some delay in event arrival
  • Periodic: generates watermarks at fixed intervals

Required Methods§

Source

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

Called when a new element arrives with the given event timestamp. Returns the new watermark if it should be emitted.

Source

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

Called periodically to generate watermarks even without new events. Returns the new watermark if it should be emitted.

Source

fn current_watermark(&self) -> Watermark

Returns the current watermark without advancing it.

Provided Methods§

Source

fn on_end_of_stream(&mut self) -> Watermark

Signals end of stream, generating the final watermark.

Implementors§