pub struct WorkerHealthTracker { /* private fields */ }Expand description
Thread-safe tracker that records per-worker health statistics.
When lease_expiry_count for a worker reaches quarantine_threshold, the
worker is marked quarantined = true. A quarantined worker should not
receive new dispatch leases until it is explicitly cleared.
An optional CircuitBreaker can be wired in via
WorkerHealthTracker::with_circuit_breaker. When a worker is quarantined,
the breaker is tripped automatically.
Implementations§
Source§impl WorkerHealthTracker
impl WorkerHealthTracker
pub fn new(quarantine_threshold: u64) -> Self
Sourcepub fn with_circuit_breaker(self, breaker: Arc<CircuitBreaker>) -> Self
pub fn with_circuit_breaker(self, breaker: Arc<CircuitBreaker>) -> Self
Attach a shared circuit breaker to this tracker.
The breaker will be tripped whenever a worker is quarantined.
Sourcepub fn record_expiry(&self, worker_id: &str) -> bool
pub fn record_expiry(&self, worker_id: &str) -> bool
Record one lease expiry for worker_id.
Returns true if the worker was just quarantined by this call.
If a circuit breaker is attached, it is tripped when quarantine occurs.
Sourcepub fn record_success(&self, worker_id: &str)
pub fn record_success(&self, worker_id: &str)
Record a successful dispatch acknowledgement for worker_id.
Clears quarantine, resets expiry counter, and resets the circuit breaker to Closed.
Sourcepub fn record_heartbeat(&self, worker_id: &str, heartbeat_ms: i64)
pub fn record_heartbeat(&self, worker_id: &str, heartbeat_ms: i64)
Record a heartbeat for worker_id and clear quarantine if set.
Sourcepub fn is_quarantined(&self, worker_id: &str) -> bool
pub fn is_quarantined(&self, worker_id: &str) -> bool
Returns true if the worker is currently quarantined.
Sourcepub fn get(&self, worker_id: &str) -> Option<WorkerHealth>
pub fn get(&self, worker_id: &str) -> Option<WorkerHealth>
Snapshot the health record for worker_id, or None if unknown.
Sourcepub fn clear_quarantine(&self, worker_id: &str)
pub fn clear_quarantine(&self, worker_id: &str)
Clear quarantine and reset expiry counter for worker_id.
Trait Implementations§
Source§impl Clone for WorkerHealthTracker
impl Clone for WorkerHealthTracker
Source§fn clone(&self) -> WorkerHealthTracker
fn clone(&self) -> WorkerHealthTracker
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more