Simple way to make a /status for your services with python and asyncio.
Project description
Status
Simple way to make a /status for your services with python and asyncio.
Install
pip install api-status
How it works ?
TL;DR;
Check a working example at: https://gitlab.com/cdlr75/status/-/blob/develop/tests/learning/example.py
Let say you have a coroutine that replies a dict with the desired status of your service.
async def status():
""" Returns our service status.
:returns: Misc info about our service.
:rtype: dict
"""
return {
"name": "MyService",
"status": "ok",
"version": "v1"
}
With status
, to expose this throught an HTTP endpoint:
from status import Server
server = Server(host="127.0.0.1", port=8080)
# register our status endpoint
server.add_route(status, method="GET", path=r"/status")
await server.start()
# the status is now available at http://127.0.0.1:8080/status
If you take care of gracefull shutdowns for your services, call the method stop
:
await server.stop()
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
api-status-1.0.0.tar.gz
(10.5 kB
view hashes)
Built Distribution
Close
Hashes for api_status-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a1c5c75aee14656732fb42a3a4fa21a3dc0a795cd0c4de6e539fdcac2e876bd |
|
MD5 | dfe39e7db15c6b85959dc7a0b12d1861 |
|
BLAKE2b-256 | 6962af7127fa279f1f22b39a380cf2922404fc24dc8f3d2eff3a6831347ed008 |