Health checks¶
- async alchemiq.check_health(*, timeout=5.0)[source]¶
Run health probes for all configured backends concurrently.
Returns a
HealthReportaggregating all component results. Probes are skipped for backends that are not configured.HealthReport.healthyisTrueonly if every component probe succeeds. Each probe is guarded bytimeoutseconds; a probe that times out or errors is recorded as unhealthy.E.g.:
from alchemiq.health import check_health report = await check_health() if not report.healthy: print(report.to_dict()) # FastAPI integration: from alchemiq.fastapi import health_router app.include_router(health_router())
- Parameters:
timeout (float) – per-probe timeout in seconds (default 5.0).
- Returns:
a
HealthReportaggregating all component results.- Return type:
Note
When no backends are configured, returns a trivially healthy report with an empty
componentstuple - useful in unit tests that haven’t calledconfigure.See also
HealthReport- the returned aggregate report.
- class alchemiq.HealthReport(healthy, components)[source]¶
Bases:
objectAggregate health report across all probed components.
Returned by
check_health().healthyisTrueonly when everyComponentHealthincomponentsis healthy.E.g.:
report = await check_health() data = report.to_dict() # {"status": "healthy", "checks": [{"name": "postgres", "healthy": True, ...}]}
See also
check_health()- produces this report.- Parameters:
healthy (bool)
components (tuple[ComponentHealth, ...])
- class alchemiq.ComponentHealth(name, healthy, latency_ms, error=None)[source]¶
Bases:
objectProbe result for a single backend component.
Returned as part of
HealthReportfromcheck_health().latency_msisNonewhen the probe did not complete (error or timeout).