Skip to main content

FlushPolicy

Trait FlushPolicy 

Source
pub trait FlushPolicy {
    // Required methods
    fn deadline<T>(&self, batch: &PendingBatch<T>) -> Option<Instant>;
    fn should_flush<T>(
        &self,
        batch: &PendingBatch<T>,
        now: Instant,
        trigger: FlushTrigger,
    ) -> bool;
}
Expand description

Decides when a pending batch is ready without owning its payloads or execution.

A deadline wakeup must either allow flushing or produce a future deadline; otherwise the caller would repeatedly poll an expired timer.

Required Methods§

Source

fn deadline<T>(&self, batch: &PendingBatch<T>) -> Option<Instant>

Returns the next timer deadline, or None when no timer is needed.

Source

fn should_flush<T>( &self, batch: &PendingBatch<T>, now: Instant, trigger: FlushTrigger, ) -> bool

Returns whether the batch should be flushed for this event at now.

Workers never flush empty batches, regardless of this decision.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§