pub struct HealthCheckRegistry { /* private fields */ }Expand description
Registry of health checks.
Collects named health checks that can be evaluated together to produce
a HealthReport.
§Example
ⓘ
let mut registry = HealthCheckRegistry::new();
// Critical check — failure makes the app "unhealthy"
registry.add("database", true, || async {
// db.ping().await?;
Ok(())
});
// Non-critical check — failure makes the app "degraded"
registry.add("cache", false, || async {
// cache.ping().await?;
Ok(())
});Implementations§
Source§impl HealthCheckRegistry
impl HealthCheckRegistry
Sourcepub fn add<F, Fut>(
&mut self,
name: impl Into<String>,
critical: bool,
check_fn: F,
)
pub fn add<F, Fut>( &mut self, name: impl Into<String>, critical: bool, check_fn: F, )
Add a named health check.
§Parameters
name: Identifier for the check (e.g., “database”, “cache”).critical: Iftrue, failure of this check makes the overall statusUnhealthy. Iffalse, failure makes itDegraded(unless another critical check fails).check_fn: Async function that returnsOk(())on success orErr(message)on failure.
Sourcepub async fn check_all(&self) -> HealthReport
pub async fn check_all(&self) -> HealthReport
Run all health checks and produce a report.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for HealthCheckRegistry
impl !RefUnwindSafe for HealthCheckRegistry
impl Send for HealthCheckRegistry
impl Sync for HealthCheckRegistry
impl Unpin for HealthCheckRegistry
impl !UnwindSafe for HealthCheckRegistry
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).