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
impl StreamingIngestor
Sourcepub fn new(source: impl Into<String>) -> Self
pub fn new(source: impl Into<String>) -> Self
Construct an ingestor with the default reorder window.
Sourcepub fn with_window(source: impl Into<String>, reorder_window_s: f64) -> Self
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).
Sourcepub fn push(&mut self, sample: ResidualSample)
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.
Sourcepub fn finish(self) -> (ResidualStream, u64)
pub fn finish(self) -> (ResidualStream, u64)
Drain the reorder buffer and return the completed stream together with the count of samples dropped during ingest.
Sourcepub fn dropped_out_of_window(&self) -> u64
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.