Health probes for Kubernetes and load balancers.
Provides liveness and readiness endpoints for container orchestration.
Chirp auto-mounts/health (liveness) and /ready(readiness) at the paths
inAppConfig (health_path / ready_path) unless a
user route already claims them./health always returns 200— it answers
"is the process alive?" (K8slivenessProbe). /readyruns every registered
HealthCheck and gates on the startup-complete flag, returning 503
plus the failure list until the app has finished startup and all checks pass (K8s
readinessProbe).
Register readiness checks before freeze withapp.add_health_check(...)::
from chirp import HealthCheck
app.add_health_check(HealthCheck("cache", check=ping_cache))
When a database is wired, Chirp auto-includes aDatabase.probe()-backed check
so/readyreflects DB connectivity with no hand-wiring. Probe checks may be
sync or async —readiness()awaits awaitable results.
health
| Name | Type | Default | Description |
|---|---|---|---|
type
|
|
— | |
qualified_name
|
|
— | |
element_type
|
|
— | |
description
|
|
— | |
source_file
|
|
— | |
line_number
|
|
— | |
is_autodoc
|
|
— | |
autodoc_element
|
|
— | |
_autodoc_template
|
|
— | |
_autodoc_url_path
|
|
— | |
_autodoc_page_type
|
|
— | |
title
|
|
— | |
doc_content_hash
|
|
— |
Symbols on this page
A single readiness check.
checkis a zero-argument callable returning truthy when healthy. It may
be sync (() -> bool) or async…
Liveness probe — is the process alive?
Returns True. Use for K8s livenessProbe. If this fails, the pod is restarted.
Readiness probe — is the app ready to receive traffic?
Runs each check (awaiting awaitable results) and returns
(all_ok, list of failure messages).…
HealthCheck
class
A single readiness check.
checkis a zero-argument callable returning truthy when healthy. It may
be sync (() -> bool) or async (() -> Awaitable[bool]); readiness()
awaits awaitable results.messageis the failure message surfaced on
/readywhen the check is unhealthy or raises.
liveness
function
def liveness() -> bool
Liveness probe — is the process alive?
Returns True. Use for K8s livenessProbe. If this fails, the pod is restarted.
No parameters.
readiness
function
async
async def readiness(checks: list[HealthCheck]) -> tuple[bool, list[str]]
Readiness probe — is the app ready to receive traffic?
Runs each check (awaiting awaitable results) and returns
(all_ok, list of failure messages). Use for K8s readinessProbe. If not
ready, the pod is removed from service endpoints.
This isasyncso checks can express async DB/Redis pings; sync checks are
supported transparently (only awaitable results are awaited).
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
checks
|
list[HealthCheck]
|
— |
View source · /home/runner/work/chirp/chirp/site/../src/chirp/health.py:1