Service health checker with liveness and readiness probes for Rust
cargo add philiprehberger-service-healthService health checker with liveness and readiness probes for Rust
[dependencies]
philiprehberger-service-health = "0.1.7"
use philiprehberger_service_health::{HealthChecker, Status};
let mut checker = HealthChecker::new();
checker.add_liveness_check("database", || {
// check database connection
Status::Healthy
});
checker.add_readiness_check("cache", || {
Status::Degraded("high latency".into())
});
let report = checker.check_health();
println!("{}", report.to_json());
println!("Healthy: {}", report.is_healthy());
// Run only liveness or readiness probes
let liveness = checker.check_liveness();
let readiness = checker.check_readiness();
| Type | Description |
|---|---|
Status | Health status: Healthy, Degraded(String), Unhealthy(String) |
CheckResult | Result of a single check with name, status, and duration |
HealthReport | Aggregated report with overall status, check results, and timestamp |
HealthChecker | Registry for health checks with liveness/readiness probe support |
cargo test
cargo clippy -- -D warnings
If you find this project useful: