Skip to main content

Simple way to make a /status for your services with python and asyncio.

Project description

Status

PEP8 coverage report

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 api-status, to expose this through 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 graceful shutdowns for your services, call the method stop:

await server.stop()

Project details


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.1.tar.gz (10.5 kB view hashes)

Uploaded Source

Built Distribution

api_status-1.0.1-py3-none-any.whl (8.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page