Skip to main content

Module health

Module health 

Source
Expand description

Health check endpoint helpers for operations.

Provides standard health check patterns:

  • Basic health: returns {"status":"healthy"} on GET /health
  • Detailed health with named checks, critical flags, and per-check latency
  • Kubernetes-style liveness (/healthz) and readiness (/ready) probes

§Example

use fastapi_core::health::{HealthCheckRegistry, HealthStatus};

let mut registry = HealthCheckRegistry::new();
registry.add("database", true, || async {
    // Check database connection
    Ok(())
});
registry.add("cache", false, || async {
    // Check cache connection (non-critical)
    Ok(())
});

let result = futures_executor::block_on(registry.check_all());
assert_eq!(result.status, HealthStatus::Healthy);

Structs§

HealthCheckRegistry
Registry of health checks.
HealthCheckResult
Result of a single named health check.
HealthReport
Aggregate result of all health checks.

Enums§

HealthStatus
Overall health status of the application.

Functions§

basic_health_handler
Create a basic health check handler that returns {"status":"healthy"}.
detailed_health_handler
Create a detailed health check handler from a registry.
liveness_handler
Create a Kubernetes liveness probe handler.
readiness_handler
Create a Kubernetes readiness probe handler from a registry.