API Reference
Core Classes
- class Probe(*args, **kwargs)[source]
Bases:
Protocol
Protocol defining the interface for a probe.
- property info: Dict[str, Any] | None
- __init__(*args, **kwargs)
- class ProbeBase(name=None, timeout=None, success_ttl=None, failed_ttl=None)[source]
Bases:
object
Base implementation of a probe.
- __init__(name=None, timeout=None, success_ttl=None, failed_ttl=None)[source]
Initialize the probe.
- Parameters:
name (
Optional
[str
]) – The name of the probe.timeout (
Optional
[int
]) – The timeout for the probe.success_ttl (
Union
[int
,timedelta
,None
]) – Cache duration for successful results. If None, successful results are not cached.failed_ttl (
Union
[int
,timedelta
,None
]) – Cache duration for failed results. If None, failed results are not cached.
- add_info(name, value)[source]
Add information to the probe result.
- Parameters:
name (
str
) – The name of the information.value (
Any
) – The value of the information.
- Return type:
None
- property info: Dict[str, Any] | None
Get the information added to the probe result.
- Returns:
The information added to the probe result.
- class CallableProbe(func, name=None, timeout=None, success_ttl=None, failed_ttl=None)[source]
Bases:
ProbeBase
A probe that wraps a callable function.
- __init__(func, name=None, timeout=None, success_ttl=None, failed_ttl=None)[source]
Initialize the probe.
- Parameters:
name (
Optional
[str
]) – The name of the probe.timeout (
Optional
[int
]) – The timeout for the probe.success_ttl (
Union
[int
,timedelta
,None
]) – Cache duration for successful results. If None, successful results are not cached.failed_ttl (
Union
[int
,timedelta
,None
]) – Cache duration for failed results. If None, failed results are not cached.
- class Probirka(success_ttl=None, failed_ttl=None)[source]
Bases:
object
Probirka is a health check manager that allows adding and running probes.
- __init__(success_ttl=None, failed_ttl=None)[source]
Initialize the Probirka instance.
- Parameters:
success_ttl (
Union
[int
,timedelta
,None
]) – Default cache duration for successful results. If None, successful results are not cached.failed_ttl (
Union
[int
,timedelta
,None
]) – Default cache duration for failed results. If None, failed results are not cached.
- add_info(name, value)[source]
Add information to the health check result.
- Parameters:
name (
str
) – The name of the information.value (
Any
) – The value of the information.
- Return type:
None
- property info: Dict[str, Any] | None
Get the information added to the health check result.
- Returns:
The information added to the health check result.
- add_probes(*probes, groups='')[source]
Add probes to the health check.
- Parameters:
probes (
Probe
) – Probes to addgroups (
Union
[str
,List
[str
]]) – Groups for optional probes. Probes without groups are required.
- Return type:
None
- add(name=None, timeout=None, groups='', success_ttl=None, failed_ttl=None)[source]
Decorator to add a callable as a probe.
- Parameters:
name (
Optional
[str
]) – Probe nametimeout (
Optional
[int
]) – Probe timeout in secondsgroups (
Union
[str
,List
[str
]]) – Groups for optional probes. Probes without groups are required.success_ttl (
Union
[int
,timedelta
,None
]) – Cache duration for successful results. If None, uses the global success_ttl setting.failed_ttl (
Union
[int
,timedelta
,None
]) – Cache duration for failed results. If None, uses the global failed_ttl setting.
- Return type:
Callable
- Returns:
Decorated function
- async run(timeout=None, with_groups='', skip_required=False)[source]
Run health check and return results.
- Parameters:
timeout (
Optional
[int
]) – Overall timeout in secondswith_groups (
Union
[str
,List
[str
]]) – Groups to run. Required probes run unless skip_required=Trueskip_required (
bool
) – Skip probes without groups
- Return type:
- Returns:
Health check result
Integrations
FastAPI
- make_fastapi_endpoint(probirka, timeout=None, with_groups='', skip_required=False, return_results=True, success_code=200, error_code=500)[source]
Create a FastAPI endpoint for a given Probirka instance.
- Parameters:
probirka (Probirka) – The Probirka instance to run.
timeout (Optional[int]) – The timeout for the Probirka run.
with_groups (Union[str, List[str]]) – Groups to include in the Probirka run.
skip_required (bool) – Whether to skip required checks.
return_results (bool) – Whether to return the results in the response.
success_code (int) – The HTTP status code for a successful response.
error_code (int) – The HTTP status code for an error response.
- Returns:
The FastAPI endpoint.
- Return type:
Callable[[], Coroutine[Any, Any, Response]]
AIOHTTP
- make_aiohttp_endpoint(probirka, timeout=None, with_groups='', skip_required=False, return_results=True, success_code=200, error_code=500)[source]
Create an aiohttp endpoint for a given Probirka instance.
- Parameters:
probirka (Probirka) – The Probirka instance to run.
timeout (Optional[int]) – The timeout for the Probirka run.
with_groups (Union[str, List[str]]) – Groups to include in the Probirka run.
skip_required (bool) – Whether to skip required checks.
return_results (bool) – Whether to return the results in the response.
success_code (int) – The HTTP status code for a successful response.
error_code (int) – The HTTP status code for an error response.
- Returns:
The aiohttp endpoint.
- Return type:
Callable[[web.Request], Coroutine[Any, Any, web.Response]]