pub struct TelemetryBuffer { /* private fields */ }Expand description
Shared event buffer. record() is cheap and lock-bound; clones are light (Arc).
Internally carries a Notify that the buffer signals when the queue length crosses
the flush_threshold — the uploader waits on this alongside its periodic ticker so
that “batch_size reached” triggers an immediate flush without waiting for the next
interval tick.
Implementations§
Source§impl TelemetryBuffer
impl TelemetryBuffer
pub fn new(capacity: usize) -> Self
Sourcepub fn set_flush_threshold(&self, threshold: usize)
pub fn set_flush_threshold(&self, threshold: usize)
Set the queue length at which record() wakes the flusher. Called by the
pipeline once batch_size is known.
Sourcepub fn size_trigger(&self) -> Arc<Notify> ⓘ
pub fn size_trigger(&self) -> Arc<Notify> ⓘ
Notifier the background flusher waits on for size-triggered flushes.
Sourcepub async fn record(&self, event: TelemetryEvent)
pub async fn record(&self, event: TelemetryEvent)
Push an event. When the queue is full, drops the oldest event to make room.
Wakes the background flusher as soon as the queue length crosses
Self::set_flush_threshold.
Sourcepub async fn drain(&self, max: usize) -> Vec<TelemetryEvent>
pub async fn drain(&self, max: usize) -> Vec<TelemetryEvent>
Drain up to max events without releasing the lock between pops.
Sourcepub async fn requeue_front(&self, events: Vec<TelemetryEvent>)
pub async fn requeue_front(&self, events: Vec<TelemetryEvent>)
Return events to the front of the queue (after a failed upload).
pub async fn len(&self) -> usize
pub async fn is_empty(&self) -> bool
Trait Implementations§
Source§impl Clone for TelemetryBuffer
impl Clone for TelemetryBuffer
Source§fn clone(&self) -> TelemetryBuffer
fn clone(&self) -> TelemetryBuffer
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more