pub struct HealthChecks { /* private fields */ }Expand description
A collection of named health checks.
Built with a fluent API and registered in the
service::Registry. The readiness endpoint
runs all checks concurrently and reports failures.
§Example
use modo::health::HealthChecks;
let checks = HealthChecks::new()
.check_fn("database", || async { Ok(()) })
.check_fn("redis", || async { Ok(()) });Implementations§
Source§impl HealthChecks
impl HealthChecks
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates an empty collection with no registered checks.
When mounted via router with no checks registered,
/_ready returns 200 OK.
Sourcepub fn check(self, name: &str, c: impl HealthCheck) -> Self
pub fn check(self, name: &str, c: impl HealthCheck) -> Self
Registers a HealthCheck implementation under the given name.
The name is recorded with the failure in the check_name tracing field
when /_ready reports a failure. Names are not required to be unique,
but uniqueness makes log triage easier.
Sourcepub fn check_fn<F, Fut>(self, name: &str, f: F) -> Self
pub fn check_fn<F, Fut>(self, name: &str, f: F) -> Self
Registers a named health check from an async closure.
The closure must return crate::Result<()> — Ok(()) means healthy,
any Err marks the service unhealthy and causes /_ready to return
503 Service Unavailable.
Trait Implementations§
Source§impl Default for HealthChecks
impl Default for HealthChecks
Source§fn default() -> Self
fn default() -> Self
Returns an empty HealthChecks collection.