pub struct PressureMonitor { /* private fields */ }Expand description
Tracks pressure metrics and derives channel pressure scores.
Implementations§
Source§impl PressureMonitor
impl PressureMonitor
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates an empty pressure monitor with the default average-utilization scorer.
Sourcepub fn with_scoring<F>(scoring: F) -> Self
pub fn with_scoring<F>(scoring: F) -> Self
Creates an empty pressure monitor using a caller-supplied scoring function.
Sourcepub fn total_consumer_count(&self) -> usize
pub fn total_consumer_count(&self) -> usize
Returns the number of consumers tracked across all channels.
Sourcepub fn record_consumer_metrics(
&mut self,
channel_id: impl Into<String>,
consumer_id: impl Into<String>,
metrics: ConsumerPressureMetrics,
) -> ChannelPressureSnapshot
pub fn record_consumer_metrics( &mut self, channel_id: impl Into<String>, consumer_id: impl Into<String>, metrics: ConsumerPressureMetrics, ) -> ChannelPressureSnapshot
Records the latest metrics for a consumer and returns the updated channel snapshot.
Sourcepub fn record_accept(
&mut self,
channel_id: impl Into<String>,
consumer_id: impl Into<String>,
) -> ChannelPressureSnapshot
pub fn record_accept( &mut self, channel_id: impl Into<String>, consumer_id: impl Into<String>, ) -> ChannelPressureSnapshot
Records one accept decision for a consumer and returns the updated channel snapshot.
Sourcepub fn record_defer(
&mut self,
channel_id: impl Into<String>,
consumer_id: impl Into<String>,
) -> ChannelPressureSnapshot
pub fn record_defer( &mut self, channel_id: impl Into<String>, consumer_id: impl Into<String>, ) -> ChannelPressureSnapshot
Records one defer decision for a consumer and returns the updated channel snapshot.
Sourcepub fn record_reject(
&mut self,
channel_id: impl Into<String>,
consumer_id: impl Into<String>,
) -> ChannelPressureSnapshot
pub fn record_reject( &mut self, channel_id: impl Into<String>, consumer_id: impl Into<String>, ) -> ChannelPressureSnapshot
Records one reject decision for a consumer and returns the updated channel snapshot.
Sourcepub fn consumer_metrics(
&self,
channel_id: &str,
consumer_id: &str,
) -> Option<&ConsumerPressureMetrics>
pub fn consumer_metrics( &self, channel_id: &str, consumer_id: &str, ) -> Option<&ConsumerPressureMetrics>
Returns the latest metrics recorded for one consumer.
Sourcepub fn consumer_utilization(
&self,
channel_id: &str,
consumer_id: &str,
) -> Option<f64>
pub fn consumer_utilization( &self, channel_id: &str, consumer_id: &str, ) -> Option<f64>
Returns the latest utilization for one consumer.
Sourcepub fn channel_pressure(&self, channel_id: &str) -> f64
pub fn channel_pressure(&self, channel_id: &str) -> f64
Returns the current aggregate pressure score for a channel.
Sourcepub fn channel_consumer_count(&self, channel_id: &str) -> usize
pub fn channel_consumer_count(&self, channel_id: &str) -> usize
Returns the current number of tracked consumers for a channel.
Sourcepub fn channel_snapshot(&self, channel_id: &str) -> ChannelPressureSnapshot
pub fn channel_snapshot(&self, channel_id: &str) -> ChannelPressureSnapshot
Returns an observable snapshot for one channel.