Configuration Reference¶
pico_actuator.config ¶
Configuration primitives for pico-actuator.
Defines :class:ActuatorSettings (loaded from the actuator config prefix) and the :class:HealthIndicator / :class:InfoContributor protocols. Both protocols mirror the FastApiConfigurer idiom in pico-fastapi: implement the protocol, mark the class @component, and it is auto-collected by pico-ioc via List[...] injection.
HealthIndicator ¶
Bases: Protocol
A component contributing one entry to /actuator/health.
Attributes:
| Name | Type | Description |
|---|---|---|
name | str | Stable key shown under |
The check method may be sync or async and may return either a mapping ({"status": "UP", ...}) or a plain truthy/falsy value.
Source code in src/pico_actuator/config.py
InfoContributor ¶
Bases: Protocol
A component contributing key/values to /actuator/info.
Source code in src/pico_actuator/config.py
ActuatorSettings dataclass ¶
Type-safe actuator settings, populated from the actuator prefix.
Mirrors FastApiSettings in pico-fastapi.
Attributes:
| Name | Type | Description |
|---|---|---|
enabled | bool | Master switch for the actuator endpoints. |
show_components | bool | Include per-indicator detail in |
check_timeout_seconds | float | Per-indicator time budget; a slower |
info | Dict[str, Any] | Static key/values exposed by |
Example
.. code-block:: yaml
# application.yaml
actuator:
enabled: true
show_components: true
check_timeout_seconds: 5.0
info:
app: my-service
build: "2026.06"
Source code in src/pico_actuator/config.py
pico_actuator.controller ¶
Actuator endpoints.
Reuses pico-fastapi's @controller / @get instead of hand-rolling an APIRouter, so route wiring, DI resolution and result normalization are inherited for free. Dependencies (settings, indicators, contributors) are constructor-injected; List[Protocol] injection is the same mechanism pico-fastapi uses for List[FastApiConfigurer].
ActuatorController ¶
Source code in src/pico_actuator/controller.py
health() async ¶
Full health: overall status plus per-component detail.
Source code in src/pico_actuator/controller.py
liveness() async ¶
Liveness: is the process responding at all? Cheap, touches no deps.
readiness() async ¶
Readiness: are dependencies healthy? Aggregate of all indicators.
Source code in src/pico_actuator/controller.py
info() async ¶
Static config info merged with dynamic contributors.
Source code in src/pico_actuator/controller.py
refresh() async ¶
Re-read config sources; report the changed top-level prefixes.
Mirror of Spring Cloud's POST /actuator/refresh: components subscribed to ConfigChanged re-read their config.
Source code in src/pico_actuator/controller.py
metrics(request) async ¶
Prometheus/OpenMetrics exposition of the default registry.
Honors the Accept header (application/openmetrics-text or Prometheus text 0.0.4). Needs the metrics extra; answers 501 when prometheus-client is not installed.
Source code in src/pico_actuator/controller.py
pico_actuator.health ¶
Health aggregation.
Pure logic on purpose: no FastAPI and no DI here, so it can be unit-tested without booting an app. The controller layer just calls :func:gather.
Indicators run concurrently, each under its own timeout. Sync check() methods are pushed to a worker thread so a slow blocking probe cannot freeze the event loop.
gather(indicators, timeout=DEFAULT_TIMEOUT) async ¶
Aggregate all indicators into an (overall, components) pair.
Indicators are probed concurrently; each gets its own timeout seconds.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indicators | List[HealthIndicator] | The health indicators to probe. | required |
timeout | float | Per-indicator time budget in seconds. | DEFAULT_TIMEOUT |
Returns:
| Type | Description |
|---|---|
str |
|
Dict[str, Any] |
|