pub struct QueueMonitor {
pub warning_threshold: f64,
pub critical_threshold: f64,
}Expand description
Monitor for queue health and utilization.
Provides real-time health checking for message queues without dynamic resizing, allowing applications to take action when queues approach capacity.
§Example
ⓘ
use ringkernel_core::queue::{QueueMonitor, SpscQueue, QueueHealth};
let queue = SpscQueue::new(1024);
let monitor = QueueMonitor::default();
// Check health periodically
match monitor.check(&queue) {
QueueHealth::Healthy => { /* normal operation */ }
QueueHealth::Warning => { /* consider throttling producers */ }
QueueHealth::Critical => { /* alert! take immediate action */ }
}Fields§
§warning_threshold: f64Utilization threshold for warning (0.0 - 1.0).
critical_threshold: f64Utilization threshold for critical (0.0 - 1.0).
Implementations§
Source§impl QueueMonitor
impl QueueMonitor
Sourcepub fn new(warning_threshold: f64, critical_threshold: f64) -> Self
pub fn new(warning_threshold: f64, critical_threshold: f64) -> Self
Create a new queue monitor with custom thresholds.
Sourcepub fn check(&self, queue: &dyn MessageQueue) -> QueueHealth
pub fn check(&self, queue: &dyn MessageQueue) -> QueueHealth
Check the health of a queue.
Sourcepub fn utilization(&self, queue: &dyn MessageQueue) -> f64
pub fn utilization(&self, queue: &dyn MessageQueue) -> f64
Get the current utilization (0.0 - 1.0).
Sourcepub fn utilization_percent(&self, queue: &dyn MessageQueue) -> f64
pub fn utilization_percent(&self, queue: &dyn MessageQueue) -> f64
Get current utilization percentage.
Sourcepub fn suggest_upgrade(
&self,
queue: &dyn MessageQueue,
current_tier: QueueTier,
) -> Option<QueueTier>
pub fn suggest_upgrade( &self, queue: &dyn MessageQueue, current_tier: QueueTier, ) -> Option<QueueTier>
Suggest whether to upgrade the queue tier based on observed utilization.
Returns Some(QueueTier) if upgrade is recommended, None otherwise.
Sourcepub fn has_drops(&self, queue: &dyn MessageQueue) -> bool
pub fn has_drops(&self, queue: &dyn MessageQueue) -> bool
Check if queue has experienced drops.
Sourcepub fn drop_rate(&self, queue: &dyn MessageQueue) -> f64
pub fn drop_rate(&self, queue: &dyn MessageQueue) -> f64
Get the drop rate (drops / total attempted enqueues).
Trait Implementations§
Source§impl Clone for QueueMonitor
impl Clone for QueueMonitor
Source§fn clone(&self) -> QueueMonitor
fn clone(&self) -> QueueMonitor
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for QueueMonitor
impl Debug for QueueMonitor
Auto Trait Implementations§
impl Freeze for QueueMonitor
impl RefUnwindSafe for QueueMonitor
impl Send for QueueMonitor
impl Sync for QueueMonitor
impl Unpin for QueueMonitor
impl UnwindSafe for QueueMonitor
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
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> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Gets the layout of the type.