pub struct JournalEventQueue { /* private fields */ }Expand description
Thread-safe unified journal event queue
Buffers all event types in memory and provides FIFO access. When the buffer is full, only SSE-only telemetry can be evicted. Correctness events are rejected if no telemetry slot can be reclaimed.
Implementations§
Source§impl JournalEventQueue
impl JournalEventQueue
Sourcepub fn new(config: JournalQueueConfig) -> Self
pub fn new(config: JournalQueueConfig) -> Self
Create a new journal event queue with specified configuration
Sourcepub fn push(&self, event: JournalEventMessage) -> Result<(), String>
pub fn push(&self, event: JournalEventMessage) -> Result<(), String>
Push an event to the queue
If the queue is at capacity, the oldest SSE-only event is dropped. A correctness event is never evicted: if the queue contains only correctness events, a new correctness event is rejected and new telemetry is dropped.
Sourcepub fn pop(&self) -> Option<JournalEventMessage>
pub fn pop(&self) -> Option<JournalEventMessage>
Pop the next event from the queue (FIFO)
Sourcepub fn push_front(&self, event: JournalEventMessage) -> Result<(), String>
pub fn push_front(&self, event: JournalEventMessage) -> Result<(), String>
Re-queue an event at the front (used when send fails)
Sourcepub fn drain_batch(&self, max: usize) -> Vec<JournalEventMessage>
pub fn drain_batch(&self, max: usize) -> Vec<JournalEventMessage>
Drain up to N events from the queue for batch sending
Sourcepub fn peek_batch_run_ids(&self, max: usize) -> Vec<String>
pub fn peek_batch_run_ids(&self, max: usize) -> Vec<String>
Return the distinct run IDs represented by the next max live events.
The background sender uses this to acquire ordering barriers before it
removes those events from the queue.
Sourcepub fn hold_run(&self, run_id: &str)
pub fn hold_run(&self, run_id: &str)
Keep run_id’s queued events out of the periodic flush until
release_run or an explicit per-run drain.
Sourcepub fn release_run(&self, run_id: &str) -> bool
pub fn release_run(&self, run_id: &str) -> bool
Return the run to normal periodic flushing. Returns whether it was held.
pub fn is_held(&self, run_id: &str) -> bool
Sourcepub fn drain_batch_for_runs(
&self,
max: usize,
allowed_run_ids: &HashSet<String>,
) -> Vec<JournalEventMessage>
pub fn drain_batch_for_runs( &self, max: usize, allowed_run_ids: &HashSet<String>, ) -> Vec<JournalEventMessage>
Drain up to max events belonging to runs whose ordering barriers are
already held. Events from other runs retain their relative FIFO order.
Sourcepub fn drain_all(&self) -> Vec<JournalEventMessage>
pub fn drain_all(&self) -> Vec<JournalEventMessage>
Drain all events from the queue
Sourcepub fn drain_run_events(&self, run_id: &str) -> Vec<JournalEventMessage>
pub fn drain_run_events(&self, run_id: &str) -> Vec<JournalEventMessage>
Drain all events for a specific run_id from the queue. Events for other runs remain in the queue (order preserved).
Sourcepub fn contains_run(&self, run_id: &str) -> bool
pub fn contains_run(&self, run_id: &str) -> bool
Whether this queue still contains an event for run_id.
Pull completion uses this while holding the run’s flush barrier: an empty result then means no flush for that run is queued or in flight.
Sourcepub fn record_sent(&self, is_sse_only: bool)
pub fn record_sent(&self, is_sse_only: bool)
Record a successful event send (for metrics)
Sourcepub fn record_sent_batch(&self, count: usize, sse_only_count: usize)
pub fn record_sent_batch(&self, count: usize, sse_only_count: usize)
Record batch of successful sends
Sourcepub fn record_error(&self)
pub fn record_error(&self)
Record an event send error (for metrics)
Sourcepub fn metrics(&self) -> JournalQueueMetrics
pub fn metrics(&self) -> JournalQueueMetrics
Get current metrics snapshot
Sourcepub fn get_metrics(&self) -> (u64, u64, u64, u64)
pub fn get_metrics(&self) -> (u64, u64, u64, u64)
Get current metrics as tuple (queued, sent, dropped, errors)
Sourcepub fn oldest_age(&self) -> Option<Duration>
pub fn oldest_age(&self) -> Option<Duration>
Get age of oldest event in queue
Sourcepub fn batch_size(&self) -> usize
pub fn batch_size(&self) -> usize
Get the configured batch size
Sourcepub fn flush_interval_ms(&self) -> u64
pub fn flush_interval_ms(&self) -> u64
Get the configured flush interval in milliseconds
Trait Implementations§
Auto Trait Implementations§
impl Freeze for JournalEventQueue
impl RefUnwindSafe for JournalEventQueue
impl Send for JournalEventQueue
impl Sync for JournalEventQueue
impl Unpin for JournalEventQueue
impl UnsafeUnpin for JournalEventQueue
impl UnwindSafe for JournalEventQueue
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request