Tiny and fast async readiness and liveness healthcheck server with no dependencies
Project description
hcheckz
Tiny asynchronous healthcheck server.
Installation
pip install hcheckz
Usage
import asyncio
import hcheckz
async def main():
# Start the healthcheck server in the background
hcheck_task = hcheckz.start_healthchecks(host="0.0.0.0", port=8080)
# Register your dependency points
hcheckz.readiness_point("kafka")
hcheckz.readiness_point("redis")
# Start main application background tasks
await asyncio.sleep(2)
hcheckz.set_ready("kafka")
await asyncio.sleep(2)
hcheckz.set_ready("redis")
# Keep the main loop alive and handle graceful shutdown
try:
await asyncio.Event().wait()
except asyncio.CancelledError:
hcheck_task.cancel()
if __name__ == "__main__":
asyncio.run(main())
Endpoints:
- /healthz
- /readyz
/healthz
200 OK status if service is at least running
/readyz
200 OK status if all of readiness points are ready and registred more than zero readiness points unless 503 Service Unavailable
200 OK
200 OK
503 Service Unavailable (0 points registred)
{ "reason": "Nothing Registred" }
503 Service Unavailable (problems)
{ "reason": "Unreadinesses", "details": { "kafka": { "code": "FATAL ERROR", "message": "Some unknown fatal error, Kafka dead." } } }
HTTP Status Codes Reference
- 200 OK
- 400 Bad Request
- 404 Not Found
- 405 Method Not Allowed
- 503 Service Unavailable
200 OK
Always returns text/plain body: 200 OK
400 Bad Request
Always returns text/plain body
400 Bad Request: Request line too long
404 Not Found
Always returns text/plain body
404 Not Found
405 Method Not Allowed
Always returns text/plain body
405 Method Not Allowed
503 Service Unavailable
Always returns application/json body
Watch endpoint [[README.md#readyz/|readyz/]]
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hcheckz-1.0.0.tar.gz.
File metadata
- Download URL: hcheckz-1.0.0.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
59a6e02f7cfaf9339666c68a6041a732245ec9c9f1db449f3a202716e54e78af
|
|
| MD5 |
195c639c8888de66666007d9eac363f0
|
|
| BLAKE2b-256 |
8a4d9ae1871a0fb3a09d2ee1578306c4cb5f91a0cfc1290914b47cbd11e9e2d6
|
File details
Details for the file hcheckz-1.0.0-py3-none-any.whl.
File metadata
- Download URL: hcheckz-1.0.0-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a5adca09d5de82dd4687ba7f994e9b28ab25d2646a734803e9a8aa35a87e7e6
|
|
| MD5 |
38d0fcf32a297f88e81e21b07816d03d
|
|
| BLAKE2b-256 |
09067180622272789edb27c7606aae2fbb016c6c3cbd3d0d8bf532b3f8b5582b
|