Skip to main content

StreamingIngestor

Struct StreamingIngestor 

Source
pub struct StreamingIngestor { /* private fields */ }
Expand description

Streaming ingestor that accepts one ResidualSample at a time and flushes a correctly-ordered prefix into an owned ResidualStream as the reorder window slides forward.

Invariant: after every StreamingIngestor::push or StreamingIngestor::finish, the underlying self.stream.samples is time-ordered (t non-decreasing).

Implementations§

Source§

impl StreamingIngestor

Source

pub fn new(source: impl Into<String>) -> Self

Construct an ingestor with the default reorder window.

Source

pub fn with_window(source: impl Into<String>, reorder_window_s: f64) -> Self

Construct an ingestor with a custom reorder window. A zero window degenerates to strictly-in-order ingest (any out-of-order sample is dropped).

Source

pub fn push(&mut self, sample: ResidualSample)

Ingest one sample. If sample.t is more than reorder_window_s behind the already-flushed frontier, the sample is dropped and dropped_out_of_window is incremented. Otherwise the sample is staged and the internal buffer is drained up to the new frontier.

Source

pub fn finish(self) -> (ResidualStream, u64)

Drain the reorder buffer and return the completed stream together with the count of samples dropped during ingest.

Source

pub fn flushed(&self) -> usize

Number of samples already flushed to the owned stream.

Source

pub fn staged(&self) -> usize

Number of samples currently staged in the reorder buffer.

Source

pub fn dropped_out_of_window(&self) -> u64

Running count of out-of-window drops. Production deployments should expose this as a Prometheus counter (Phase-C4) and alert on any non-zero value.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V