A compact asynchronous healthcheck using only the standard library
Project description
async-healthcheck
async-healthcheck
is a compact asynchronous health check library built using only the Python standard library. It provides a simple way to monitor the health of your application by checking the status of various synchronous and asynchronous functions.
Installation
You can install async-healthcheck
directly from PyPI:
pip install async-healthcheck
Usage
Here is a basic usage example:
from async_healthcheck import start_healthcheck
def sync_check():
# Perform some synchronous health check (e.g., check database connection)
return True
async def async_check():
# Perform some asynchronous health check (e.g., check API availability)
return True
async def main():
server = await start_healthcheck(
sync_callables=[sync_check],
async_callables=[async_check],
host="127.0.0.1",
path="/healthcheck",
port=8000,
)
# The server is now running and can be accessed at http://127.0.0.1:8000/healthcheck
if __name__ == "__main__":
import asyncio
asyncio.run(main())
In this example, start_healthcheck
starts a health check server that runs the provided synchronous and asynchronous checks when a GET request is made to the specified path (default is /healthcheck
). If all checks pass, it returns a 200 status code; if any check fails, it returns a 500 status code.
Testing
Tests are located in the tests
directory and can be run using the standard Python unittest module:
PYTHONPATH="async_healthcheck" poetry run python -m unittest discover -s tests
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file async_healthcheck-0.6.0.tar.gz
.
File metadata
- Download URL: async_healthcheck-0.6.0.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.9.19 Linux/6.5.0-1016-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 43731b2c4e0d0f21ab15b6c5d98548e801c1783534e0e9388f94fbef1d20cafb |
|
MD5 | 9506b8a01c57451404dc9caed0b1baca |
|
BLAKE2b-256 | 6d1a8797f02efeebd17c013a7c9845f3bcad1d07cccb0c1ca5766bdefb923803 |
File details
Details for the file async_healthcheck-0.6.0-py3-none-any.whl
.
File metadata
- Download URL: async_healthcheck-0.6.0-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.9.19 Linux/6.5.0-1016-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3fd1742e3d8250adf58059d0366606aa06bbb018b1d47ff6b920559083d1248a |
|
MD5 | e5cd844207079b529333c50a6f91792f |
|
BLAKE2b-256 | c00617da699dc92cd859b07821d0e9793ce42f4a743e9bea7fece29367909b11 |