pub struct HealthChecker {
pub failure_threshold: u32,
pub recovery_cooldown: Duration,
/* private fields */
}Expand description
Health checker: tracks each slave’s health status and supports failover
Fields§
§failure_threshold: u32Consecutive failure count threshold; when reached, the slave is marked Unhealthy
recovery_cooldown: DurationAuto failover recovery cooldown (how long after health check recovery before rejoining the cluster)
Implementations§
Source§impl HealthChecker
impl HealthChecker
pub fn new(failure_threshold: u32) -> Self
Sourcepub fn set_health(&self, slave: &str, health: SlaveHealth)
pub fn set_health(&self, slave: &str, health: SlaveHealth)
Mark slave with the specified health status
Sourcepub fn record_failure(&self, slave: &str) -> bool
pub fn record_failure(&self, slave: &str) -> bool
Record a failure; when threshold is reached, automatically mark as Unhealthy Returns true if failover was triggered
Sourcepub fn record_success(&self, slave: &str)
pub fn record_success(&self, slave: &str)
Record a success, resetting the failure count
Sourcepub fn health(&self, slave: &str) -> Option<SlaveHealth>
pub fn health(&self, slave: &str) -> Option<SlaveHealth>
Query slave health status; returns None if not registered
Sourcepub fn list_by_health(&self, health: SlaveHealth) -> Vec<String>
pub fn list_by_health(&self, health: SlaveHealth) -> Vec<String>
List all slaves in the specified state
Sourcepub fn healthy_slaves(&self) -> Vec<String>
pub fn healthy_slaves(&self) -> Vec<String>
Return the list of all healthy slaves
Sourcepub fn unhealthy_slaves(&self) -> Vec<String>
pub fn unhealthy_slaves(&self) -> Vec<String>
Return the list of all unhealthy slaves
Sourcepub fn failure_count(&self, slave: &str) -> u32
pub fn failure_count(&self, slave: &str) -> u32
Return the current consecutive failure count
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for HealthChecker
impl RefUnwindSafe for HealthChecker
impl Send for HealthChecker
impl Sync for HealthChecker
impl Unpin for HealthChecker
impl UnsafeUnpin for HealthChecker
impl UnwindSafe for HealthChecker
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