Health checks for Rust applications
| Tier | operations |
| Role | unclassified (baselined) |
| Path | crates/operations/health |
| Edition | 2021 |
| Targets | operations_health |
| Public items | 56 across 0 modules |
| Tests | 23 |
What it is for
Health check library crates for Rust applications.
This crate provides abstractions for implementing health checks, readiness probes, and liveness probes for services.
Capabilities
AlwaysHealthy
Health check library crates for Rust applications.
| Item |
|---|
pub struct AlwaysHealthy |
AlwaysHealthy :: fn new(name : impl Into <String>) -> Self |
AlwaysHealthy :: fn name(& self) -> & str |
AlwaysHealthy :: async fn check(& self) -> CheckResult |
CheckResult
Health check library crates for Rust applications.
| Item |
|---|
pub struct CheckResult |
CheckResult :: fn healthy(name : impl Into <String>) -> Self |
CheckResult :: fn degraded(name : impl Into <String>, message : impl Into <String>) -> Self |
CheckResult :: fn unhealthy(name : impl Into <String>, message : impl Into <String>) -> Self |
CheckResult :: fn with_duration(mut self, duration_ms : u64) -> Self |
CheckResult :: fn with_detail(mut self, key : impl Into <String>, value : impl Serialize) -> Self |
DatabaseCheck
Health check library crates for Rust applications.
| Item |
|---|
pub struct DatabaseCheck |
DatabaseCheck :: fn new <F>(name : impl Into <String>, check_fn : F) -> Self where F : Fn() -> bool + Send + Sync + 'static, |
DatabaseCheck :: fn name(& self) -> & str |
DatabaseCheck :: async fn check(& self) -> CheckResult |
DependencyCheck
Health check library crates for Rust applications.
| Item |
|---|
pub struct DependencyCheck |
DependencyCheck :: fn new(name : impl Into <String>, url : impl Into <String>) -> Self |
DependencyCheck :: fn with_timeout(mut self, timeout : std::time::Duration) -> Self |
DependencyCheck :: fn name(& self) -> & str |
DependencyCheck :: async fn check(& self) -> CheckResult |
DependencyCheck :: fn timeout(& self) -> std::time::Duration |
HealthCheck
Health check library crates for Rust applications.
| Item |
|---|
pub trait HealthCheck |
HealthChecker
Health check library crates for Rust applications.
| Item |
|---|
pub struct HealthChecker |
HealthChecker :: fn new() -> Self |
HealthChecker :: fn with_check(mut self, check : impl HealthCheck + 'static) -> Self |
HealthChecker :: fn with_version(mut self, version : impl Into <String>) -> Self |
HealthChecker :: fn with_service(mut self, service : impl Into <String>) -> Self |
HealthChecker :: async fn check(& self) -> HealthResponse |
HealthChecker :: async fn liveness(& self) -> HealthResponse |
HealthChecker :: async fn readiness(& self) -> HealthResponse |
HealthError
Health check library crates for Rust applications.
| Item |
|---|
pub enum HealthError |
HealthResponse
Health check library crates for Rust applications.
| Item |
|---|
pub struct HealthResponse |
HealthResponse :: fn new(checks : Vec <CheckResult>) -> Self |
HealthResponse :: fn with_version(mut self, version : impl Into <String>) -> Self |
HealthResponse :: fn with_service(mut self, service : impl Into <String>) -> Self |
HealthResponse :: fn http_status_code(& self) -> u16 |
HealthStatus
Health check library crates for Rust applications.
| Item |
|---|
pub enum HealthStatus |
HealthStatus :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result |
HealthStatus :: fn is_ok(& self) -> bool |
HealthStatus :: fn is_ready(& self) -> bool |
HealthStatus :: fn is_alive(& self) -> bool |
HealthStatus :: fn http_status_code(& self) -> u16 |
MemoryCheck
Health check library crates for Rust applications.
| Item |
|---|
pub struct MemoryCheck |
MemoryCheck :: fn new(threshold_mb : u64) -> Self |
MemoryCheck :: fn name(& self) -> & str |
MemoryCheck :: async fn check(& self) -> CheckResult |
MemoryCheck :: fn is_critical(& self) -> bool |
Result
Health check library crates for Rust applications.
| Item |
|---|
pub type Result<T>: std::result::Result <T, HealthError> |
ThresholdConfig
Health check library crates for Rust applications.
| Item |
|---|
pub struct ThresholdConfig |
ThresholdConfig :: fn new(warning : f64, critical : f64) -> Self |
ThresholdConfig :: fn evaluate(& self, value : f64) -> HealthStatus |
UptimeCheck
Health check library crates for Rust applications.
| Item |
|---|
pub struct UptimeCheck |
UptimeCheck :: fn new() -> Self |
UptimeCheck :: fn default() -> Self |
UptimeCheck :: fn name(& self) -> & str |
UptimeCheck :: async fn check(& self) -> CheckResult |
UptimeCheck :: fn is_critical(& self) -> bool |
How to use it
No examples/ target and no doctest in this crate's rustdoc. The tests listed under Verification are the closest executable usage.
Module structure
No public modules: the crate root is its whole surface.
Public surface
`crate root`
| Item | What it is |
|---|---|
pub enum HealthError | Errors that can occur with health checks. |
pub type Result<T>: std::result::Result <T, HealthError> | Result type for health operations. |
pub enum HealthStatus | Health status. |
HealthStatus :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result | — |
HealthStatus :: fn is_ok(& self) -> bool | Returns true if the status is healthy or degraded. |
HealthStatus :: fn is_ready(& self) -> bool | Returns true if the service should receive traffic. |
HealthStatus :: fn is_alive(& self) -> bool | Returns true if the service is alive. |
HealthStatus :: fn http_status_code(& self) -> u16 | Returns the HTTP status code for this health status. |
pub struct CheckResult | Result of a health check. |
CheckResult :: fn healthy(name : impl Into <String>) -> Self | Creates a healthy result. |
CheckResult :: fn degraded(name : impl Into <String>, message : impl Into <String>) -> Self | Creates a degraded result. |
CheckResult :: fn unhealthy(name : impl Into <String>, message : impl Into <String>) -> Self | Creates an unhealthy result. |
CheckResult :: fn with_duration(mut self, duration_ms : u64) -> Self | Sets the duration. |
CheckResult :: fn with_detail(mut self, key : impl Into <String>, value : impl Serialize) -> Self | Adds a detail. |
pub trait HealthCheck | Health check trait. |
pub struct HealthResponse | Aggregated health response. |
HealthResponse :: fn new(checks : Vec <CheckResult>) -> Self | Creates a new health response. |
HealthResponse :: fn with_version(mut self, version : impl Into <String>) -> Self | Sets the service version. |
HealthResponse :: fn with_service(mut self, service : impl Into <String>) -> Self | Sets the service name. |
HealthResponse :: fn http_status_code(& self) -> u16 | Returns the HTTP status code. |
pub struct HealthChecker | Health checker that runs multiple checks. |
HealthChecker :: fn new() -> Self | Creates a new health checker. |
HealthChecker :: fn with_check(mut self, check : impl HealthCheck + 'static) -> Self | Adds a health check. |
HealthChecker :: fn with_version(mut self, version : impl Into <String>) -> Self | Sets the service version. |
HealthChecker :: fn with_service(mut self, service : impl Into <String>) -> Self | Sets the service name. |
HealthChecker :: async fn check(& self) -> HealthResponse | Runs all health checks. |
HealthChecker :: async fn liveness(& self) -> HealthResponse | Runs only liveness checks (non-critical checks). |
HealthChecker :: async fn readiness(& self) -> HealthResponse | Runs readiness checks. |
pub struct AlwaysHealthy | Simple always-healthy check. |
AlwaysHealthy :: fn new(name : impl Into <String>) -> Self | Creates a new always-healthy check. |
AlwaysHealthy :: fn name(& self) -> & str | — |
AlwaysHealthy :: async fn check(& self) -> CheckResult | — |
pub struct DatabaseCheck | Database health check. |
DatabaseCheck :: fn new <F>(name : impl Into <String>, check_fn : F) -> Self where F : Fn() -> bool + Send + Sync + 'static, | Creates a new database check. |
DatabaseCheck :: fn name(& self) -> & str | — |
DatabaseCheck :: async fn check(& self) -> CheckResult | — |
pub struct MemoryCheck | Memory health check. |
MemoryCheck :: fn new(threshold_mb : u64) -> Self | Creates a new memory check with threshold in MB. |
MemoryCheck :: fn name(& self) -> & str | — |
MemoryCheck :: async fn check(& self) -> CheckResult | — |
MemoryCheck :: fn is_critical(& self) -> bool | — |
pub struct UptimeCheck | Uptime check. |
UptimeCheck :: fn new() -> Self | Creates a new uptime check. |
UptimeCheck :: fn default() -> Self | — |
UptimeCheck :: fn name(& self) -> & str | — |
UptimeCheck :: async fn check(& self) -> CheckResult | — |
UptimeCheck :: fn is_critical(& self) -> bool | — |
pub struct DependencyCheck | Dependency check for external services. |
DependencyCheck :: fn new(name : impl Into <String>, url : impl Into <String>) -> Self | Creates a new dependency check. |
DependencyCheck :: fn with_timeout(mut self, timeout : std::time::Duration) -> Self | Sets the timeout. |
DependencyCheck :: fn name(& self) -> & str | — |
DependencyCheck :: async fn check(& self) -> CheckResult | — |
DependencyCheck :: fn timeout(& self) -> std::time::Duration | — |
pub struct ThresholdConfig | Threshold-based check result. |
ThresholdConfig :: fn new(warning : f64, critical : f64) -> Self | Creates a new threshold config. |
ThresholdConfig :: fn evaluate(& self, value : f64) -> HealthStatus | Evaluates a value against thresholds. |
No pub use re-exports: every item above is declared in this crate.
Boundary
Depends on no other workspace tier.
Shares tier operations with 40 other crates: operations-approval-workflow, operations-assessments, operations-block-imaging, operations-boot-media, operations-browser-agent-worker, operations-camera-discovery, operations-camera-liveview, operations-camera-registry, … (40 total).
_What this crate deliberately does NOT own is a judgment. No committed registry records one for it, so none is stated here._
Where it sits
| Tier (ontology) | operations |
| Architectural role (taxonomy) | unclassified (baselined) |
| Location | crates/operations/health |
| Vocabulary in force (lexicon) | current |
Dependencies
Runtime, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
async-trait | ^0.1 | — | no | always |
chrono | ^0.4 | serde | no | always |
serde | ^1 | derive | no | always |
serde_json | ^1 | — | no | always |
thiserror | ^2 | — | no | always |
Development, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
tokio | ^1 | full | no | always |
Build. None.
Depended on by. 1 workspace crate.
Signal flow — what reaches this crate, and what it reaches.
flowchart LR n_application_health["application-health"] -->|uses| SELF SELF["operations-health"] classDef self fill:#1f883d,stroke:#1f883d,color:#fff; class SELF self;
Feature flags
No Cargo features are defined: every capability is unconditional, so no consumer can receive a half-wired crate.
Targets
| Kind | Name | Source |
|---|---|---|
| lib | operations_health | `src/lib.rs` |
Error model
| Error type | Named by |
|---|---|
HealthError | Result |
Operational characteristics
| Property | Evidence |
|---|---|
| async public surface | yes |
| async runtime | none detected |
| database access | none detected |
| network I/O | none detected |
| unsafe code | none detected |
| environment variables | none detected |
No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.
Configuration
No environment variable is read with a literal name anywhere in this crate. A variable whose key is computed at run time cannot be listed here, and is not claimed to be absent.
Related capabilities
1 workspace crate depends on this one: application-health.
Verification
| Kind | Count |
|---|---|
| Unit tests | 23 |
| Integration tests | 0 |
| Examples | 0 |
| Doctests | 0 |
Evidence by module. How often each public module is named by something executable.
| Module | Tests | Examples | Consumers |
|---|---|---|---|
crate root | 13 | 0 | 1 |
What the tests establish, by name:
test_always_healthy_check—src/lib.rstest_check_result_degraded—src/lib.rstest_check_result_healthy—src/lib.rstest_check_result_unhealthy—src/lib.rstest_check_result_with_details—src/lib.rstest_database_check_healthy—src/lib.rstest_database_check_unhealthy—src/lib.rstest_dependency_check_timeout—src/lib.rstest_error_display—src/lib.rstest_health_checker—src/lib.rstest_health_checker_liveness—src/lib.rstest_health_checker_readiness—src/lib.rstest_health_response_aggregate_degraded—src/lib.rstest_health_response_aggregate_unhealthy—src/lib.rstest_health_response_new—src/lib.rstest_health_response_serialization—src/lib.rstest_health_status_display—src/lib.rstest_health_status_http_code—src/lib.rstest_health_status_is_ok—src/lib.rstest_health_status_is_ready—src/lib.rstest_memory_check_not_critical—src/lib.rstest_threshold_config_evaluate—src/lib.rstest_uptime_check—src/lib.rs
Documentation coverage
| Measure | Documented | Total |
|---|---|---|
| Public items with rustdoc | 41 | 56 |
Public modules with a //! block | 0 | 0 |
pie showData
title Public items with rustdoc
"Documented" : 41
"No rustdoc detected" : 15
Metrics
| Metric | Value |
|---|---|
| Rust source files | 1 |
| Source lines | 774 |
| Code lines | 577 |
| Public API items | 56 |
| Public modules | 0 |
| Tests | 23 |
| Examples | 0 |
| Cargo features | 0 |
| Direct runtime dependencies | 5 |
| Workspace reverse dependencies | 1 |
pie showData
title Public API by kind
"enum" : 2
"method" : 43
"struct" : 9
"trait" : 1
"type alias" : 1
pie showData
title Rust source composition
"Code" : 577
"Blank or comment" : 197
Generation
Rendered by tools-corpus corpus readme from repository evidence alone, renderer schema 2, lexicon current. No model, network service or database was consulted. Regenerate with tools-corpus corpus readme --write; verify with --check.