pub struct RateLimitMonitor { /* private fields */ }Expand description
限流监控器
定期采样指标并触发告警。适用于长期运行的限流器。
Implementations§
Source§impl RateLimitMonitor
impl RateLimitMonitor
Sourcepub fn new(metrics: RateLimitMetrics, alert_threshold: f64) -> Self
pub fn new(metrics: RateLimitMetrics, alert_threshold: f64) -> Self
创建监控器
metrics:指标收集器alert_threshold:拒绝率告警阈值(0.0~1.0)
Sourcepub fn sample(&self) -> MetricsSnapshot
pub fn sample(&self) -> MetricsSnapshot
采样并存储快照
Sourcepub fn check_alert(&self) -> Option<Alert>
pub fn check_alert(&self) -> Option<Alert>
检查是否触发告警
Sourcepub fn last_snapshot(&self) -> Option<MetricsSnapshot>
pub fn last_snapshot(&self) -> Option<MetricsSnapshot>
获取上次快照
Sourcepub fn metrics(&self) -> &RateLimitMetrics
pub fn metrics(&self) -> &RateLimitMetrics
获取指标收集器
Auto Trait Implementations§
impl !Freeze for RateLimitMonitor
impl RefUnwindSafe for RateLimitMonitor
impl Send for RateLimitMonitor
impl Sync for RateLimitMonitor
impl Unpin for RateLimitMonitor
impl UnsafeUnpin for RateLimitMonitor
impl UnwindSafe for RateLimitMonitor
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
Mutably borrows from an owned value. Read more