Struct QueueMonitor
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§
§impl QueueMonitor
impl QueueMonitor
pub fn new(warning_threshold: f64, critical_threshold: f64) -> QueueMonitor
pub fn new(warning_threshold: f64, critical_threshold: f64) -> QueueMonitor
Create a new queue monitor with custom thresholds.
pub fn check(&self, queue: &dyn MessageQueue) -> QueueHealth
pub fn check(&self, queue: &dyn MessageQueue) -> QueueHealth
Check the health of a queue.
pub fn utilization(&self, queue: &dyn MessageQueue) -> f64
pub fn utilization(&self, queue: &dyn MessageQueue) -> f64
Get the current utilization (0.0 - 1.0).
pub fn utilization_percent(&self, queue: &dyn MessageQueue) -> f64
pub fn utilization_percent(&self, queue: &dyn MessageQueue) -> f64
Get current utilization percentage.
pub 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.
pub fn has_drops(&self, queue: &dyn MessageQueue) -> bool
pub fn has_drops(&self, queue: &dyn MessageQueue) -> bool
Check if queue has experienced drops.
pub 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§
§impl Clone for QueueMonitor
impl Clone for QueueMonitor
§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 more§impl Debug for QueueMonitor
impl Debug for QueueMonitor
§impl Default for QueueMonitor
impl Default for QueueMonitor
§fn default() -> QueueMonitor
fn default() -> QueueMonitor
Returns the “default value” for a type. Read more
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§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
§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,
§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
§fn deserialize(
&self,
deserializer: &mut D,
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>
Deserializes using the given deserializer
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
§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.