pub struct HealthRegistry { /* private fields */ }Expand description
Active health state shared by one or more BackendViews.
Registries use full backend identity by default. Callers can supply an equivalence key to intentionally share probes across backend variants.
Implementations§
Source§impl HealthRegistry
impl HealthRegistry
Sourcepub fn with_equivalence(
equivalence_key: impl Fn(&Backend) -> u64 + Send + Sync + 'static,
) -> Self
pub fn with_equivalence( equivalence_key: impl Fn(&Backend) -> u64 + Send + Sync + 'static, ) -> Self
Create an empty registry using equivalence_key to group targets.
Backends that produce the same u64 key share one health state and
probe. Callers are responsible for ensuring that backends which need
independent health state produce distinct keys.
Sourcepub fn set_health_check(&self, hc: Box<dyn HealthCheck + Send + Sync + 'static>)
pub fn set_health_check(&self, hc: Box<dyn HealthCheck + Send + Sync + 'static>)
Set the health-check implementation used by every view in this registry.
§Panics
Panics if a health check has already been set.
Sourcepub fn target_count(&self) -> usize
pub fn target_count(&self) -> usize
Return the number of distinct backend targets currently being tracked.
Targets that produce the same registry health key count as one target.
Sourcepub async fn run_health_check(&self, parallel: bool)
pub async fn run_health_check(&self, parallel: bool)
Run one active health-check pass over the union of all registered views.
When parallel is true, all targets are checked concurrently.
Dropping the returned future cancels the pass: outstanding per-target checks are aborted rather than left running to completion, so targets not yet reported keep their previous health.