pub struct HealthMonitor {
pub state: RwLock<HealthState>,
pub failure_count: RwLock<u32>,
pub last_healthy: RwLock<Option<Instant>>,
pub buffer: RwLock<VecDeque<InboundMessage>>,
pub max_buffer_size: usize,
}Expand description
Health monitor state
Fields§
§state: RwLock<HealthState>Current health state
failure_count: RwLock<u32>Consecutive failure count
last_healthy: RwLock<Option<Instant>>Last successful health check
buffer: RwLock<VecDeque<InboundMessage>>Buffered messages during outage
max_buffer_size: usizeMaximum buffer size
Implementations§
Source§impl HealthMonitor
impl HealthMonitor
pub fn new(max_buffer_size: usize) -> Self
Sourcepub async fn get_state(&self) -> HealthState
pub async fn get_state(&self) -> HealthState
Get current state
Sourcepub async fn record_success(&self) -> Option<HealthState>
pub async fn record_success(&self) -> Option<HealthState>
Record a successful health check
Sourcepub async fn record_failure(&self, alert_threshold: u32) -> Option<HealthState>
pub async fn record_failure(&self, alert_threshold: u32) -> Option<HealthState>
Record a failed health check
Sourcepub async fn buffer_message(&self, message: InboundMessage) -> bool
pub async fn buffer_message(&self, message: InboundMessage) -> bool
Buffer a message during outage
Sourcepub async fn drain_buffer(&self) -> Vec<InboundMessage>
pub async fn drain_buffer(&self) -> Vec<InboundMessage>
Drain buffered messages
Sourcepub async fn buffer_size(&self) -> usize
pub async fn buffer_size(&self) -> usize
Get buffer size
Sourcepub async fn last_healthy_ago(&self) -> Option<Duration>
pub async fn last_healthy_ago(&self) -> Option<Duration>
Get last healthy timestamp
Auto Trait Implementations§
impl !Freeze for HealthMonitor
impl !RefUnwindSafe for HealthMonitor
impl Send for HealthMonitor
impl Sync for HealthMonitor
impl Unpin for HealthMonitor
impl UnsafeUnpin for HealthMonitor
impl !UnwindSafe for HealthMonitor
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