pub struct HealthCheck {
pub state: EngineState,
pub ready: bool,
pub sync_engine_accepting_writes: bool,
pub peers_total: usize,
pub peers_connected: usize,
pub peers_circuit_open: usize,
pub peers_catching_up: usize,
pub peers: Vec<PeerHealth>,
pub healthy: bool,
}Expand description
Comprehensive health status of the replication engine.
This struct provides all the information needed for:
/readyendpoint: Just checkreadyfield/healthendpoint: Full diagnostics with per-peer status- Metrics dashboards: Peer connectivity, lag, circuit states
§Data Sources
All data is cached from internal state - no network I/O during health check:
- Engine state: From internal watch channel
- Peer status: From
PeerConnectionatomics and mutexes - Sync-engine health: From
SyncEngineRef::should_accept_writes()
§Example
let health = engine.health_check().await;
if health.ready {
// Ready for traffic
} else {
// Log diagnostics
eprintln!("Engine not ready: state={}, peers_connected={}/{}",
health.state, health.peers_connected, health.peers_total);
}Fields§
§state: EngineStateCurrent engine lifecycle state.
Source: Cached from state_tx watch channel.
ready: boolWhether the engine is ready for traffic.
Source: Derived from state == Running && peers_connected > 0.
sync_engine_accepting_writes: boolWhether the local sync-engine is accepting writes.
Source: From sync_engine.should_accept_writes().
false when sync-engine is under critical memory pressure.
peers_total: usizeTotal number of configured peers.
peers_connected: usizeNumber of peers currently connected.
peers_circuit_open: usizeNumber of peers with open circuit breakers (temporarily excluded).
peers_catching_up: usizeNumber of peers we’re currently catching up with (lagging behind).
peers: Vec<PeerHealth>Per-peer health details.
healthy: boolOverall health verdict for load balancer decisions. Source: Derived from:
state == Runningpeers_connected > 0sync_engine_accepting_writes == true
Implementations§
Source§impl HealthCheck
impl HealthCheck
Sourcepub fn has_healthy_peer(&self) -> bool
pub fn has_healthy_peer(&self) -> bool
Check if at least one peer is healthy and connected.
Sourcepub fn max_lag_ms(&self) -> Option<u64>
pub fn max_lag_ms(&self) -> Option<u64>
Get the maximum lag across all peers (in milliseconds).
Returns None if no peers have reported lag.
Sourcepub fn unhealthy_peers(&self) -> Vec<&str>
pub fn unhealthy_peers(&self) -> Vec<&str>
Get peer IDs that have open circuit breakers.
Trait Implementations§
Source§impl Clone for HealthCheck
impl Clone for HealthCheck
Source§fn clone(&self) -> HealthCheck
fn clone(&self) -> HealthCheck
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for HealthCheck
impl RefUnwindSafe for HealthCheck
impl Send for HealthCheck
impl Sync for HealthCheck
impl Unpin for HealthCheck
impl UnwindSafe for HealthCheck
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more