fast-healthchecks


Namefast-healthchecks JSON
Version 0.1.3 PyPI version JSON
download
home_pageNone
SummaryFastHealthchecks
upload_time2024-12-10 02:05:35
maintainerNone
docs_urlNone
authorNone
requires_python<4.0.0,>=3.10.0
licenseMIT License Copyright (c) 2024 Vladislav Shepilov Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords healthcheck library fastapi starlette faststream litestar asyncpg psycopg redis aio-pika httpx aiokafka motor
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <h1 align="center" style="vertical-align: middle;">
  <img src="https://raw.githubusercontent.com/shepilov-vladislav/fast-healthchecks/refs/heads/main/docs/img/green.svg" width="30"> <strong>FastHealthcheck</strong>
</h1>

<b>Framework agnostic health checks with integrations for most popular ASGI frameworks: [FastAPI](https://github.com/fastapi/fastapi) / [Faststream](https://github.com/airtai/faststream) / [Litestar](https://github.com/litestar-org/litestar) to help you to implement the [Health Check API](https://microservices.io/patterns/observability/health-check-api.html) pattern</b>

---

<p align="center">

  <a href="https://github.com/shepilov-vladislav/fast-healthchecks/actions/workflows/1_test.yml" target="_blank">
    <img src="https://github.com/shepilov-vladislav/fast-healthchecks/actions/workflows/1_test.yml/badge.svg?branch=main" alt="Test Passing"/>
  </a>

  <a href="https://codecov.io/gh/shepilov-vladislav/fast-healthchecks" target="_blank">
    <img src="https://codecov.io/gh/shepilov-vladislav/fast-healthchecks/branch/main/graph/badge.svg?token=ddDOL8qZLp" alt="Coverage"/>
  </a>

  <!-- <a href="https://www.pepy.tech/projects/fast-healthchecks" target="_blank">
    <img src="https://static.pepy.tech/personalized-badge/fast-healthchecks?period=month&units=international_system&left_color=grey&right_color=green&left_text=downloads/month" alt="Downloads"/>
  </a> -->

  <a href="https://pypi.org/project/fast-healthchecks" target="_blank">
    <img src="https://img.shields.io/pypi/v/fast-healthchecks?label=PyPI" alt="Package version"/>
  </a>

  <a href="https://pypi.org/project/fast-healthchecks" target="_blank">
    <img src="https://img.shields.io/pypi/pyversions/fast-healthchecks.svg" alt="Supported Python versions"/>
  </a>

  <a href="https://github.com/shepilov-vladislav/fast-healthchecks/blob/main/LICENSE" target="_blank">
    <img src="https://img.shields.io/github/license/shepilov-vladislav/fast-healthchecks.png" alt="License"/>
  </a>

<p>

---

## Installation

With `pip`:
```bash
pip install fast-healthcheck
```

With `poetry`:
```bash
poetry add fast-healthcheck
```

With `uv`:
```bash
uv add fast-healthcheck
```

## Quick Start

Examples:
- [FastAPI example](./examples/fastapi_example)
- [Faststream example](./examples/faststream_example)
- [Litestar example](./examples/litestar_example)

```python
import asyncio
import os
import time

from fastapi import FastAPI

from fast_healthchecks.checks.function import FunctionHealthCheck
from fast_healthchecks.checks.kafka import KafkaHealthCheck
from fast_healthchecks.checks.mongo import MongoHealthCheck
from fast_healthchecks.checks.postgresql.asyncpg import PostgreSQLAsyncPGHealthCheck
from fast_healthchecks.checks.postgresql.psycopg import PostgreSQLPsycopgHealthCheck
from fast_healthchecks.checks.rabbitmq import RabbitMQHealthCheck
from fast_healthchecks.checks.redis import RedisHealthCheck
from fast_healthchecks.checks.url import UrlHealthCheck
from fast_healthchecks.integrations.fastapi import HealthcheckRouter, Probe


def sync_dummy_check() -> bool:
    time.sleep(0.1)
    return True


async def async_dummy_check() -> bool:
    await asyncio.sleep(0.1)
    return True


app = FastAPI()
app.include_router(
    HealthcheckRouter(
        Probe(
            name="liveness",
            checks=[
                FunctionHealthCheck(func=sync_dummy_check, name="Sync dummy"),
            ],
        ),
        Probe(
            name="readiness",
            checks=[
                KafkaHealthCheck(
                    bootstrap_servers=os.environ["KAFKA_BOOTSTRAP_SERVERS"],
                    name="Kafka",
                ),
                MongoHealthCheck.from_dsn(os.environ["MONGO_DSN"], name="Mongo"),
                PostgreSQLAsyncPGHealthCheck.from_dsn(os.environ["POSTGRES_DSN"], name="PostgreSQL asyncpg"),
                PostgreSQLPsycopgHealthCheck.from_dsn(os.environ["POSTGRES_DSN"], name="PostgreSQL psycopg"),
                RabbitMQHealthCheck.from_dsn(os.environ["RABBITMQ_DSN"], name="RabbitMQ"),
                RedisHealthCheck.from_dsn(os.environ["REDIS_DSN"], name="Redis"),
                UrlHealthCheck(url="https://httpbin.org/status/200", name="URL 200"),
            ],
        ),
        Probe(
            name="startup",
            checks=[
                FunctionHealthCheck(func=async_dummy_check, name="Async dummy"),
            ],
        ),
        debug=True,
        prefix="/health",
    ),
)
```

## Development

### Setup environment

```bash
git clone https://github.com/shepilov-vladislav/fast-healthchecks.git
cd fast-healthchecks
uv sync --group=dev --group=docs --all-extras
```

### Run linters

```bash
make lint
```

### Run all tests

```bash
make tests-all
```

### Serve documentation

```bash
make serve-docs
```

## Known alternatives

- [FastAPI Health](https://github.com/Kludex/fastapi-health)
- [FastAPI Health Monitor](https://github.com/adamkirchberger/fastapi-health-monitor)
- [fastapi_healthz](https://github.com/matteocacciola/fastapi_healthz)
- [fastapi_healthcheck](https://github.com/jtom38/fastapi_healthcheck)

## License

This project is licensed under the terms of the MIT license.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "fast-healthchecks",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0.0,>=3.10.0",
    "maintainer_email": "Vladislav Shepilov <shepilov.v@protonmail.com>",
    "keywords": "healthcheck, library, fastapi, starlette, faststream, litestar, asyncpg, psycopg, redis, aio-pika, httpx, aiokafka, motor",
    "author": null,
    "author_email": "Vladislav Shepilov <shepilov.v@protonmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/10/e9/7b0eab1f33d8e581bfa00f6414109b6266d50f171ced39e388e2eb53486a/fast_healthchecks-0.1.3.tar.gz",
    "platform": null,
    "description": "<h1 align=\"center\" style=\"vertical-align: middle;\">\n  <img src=\"https://raw.githubusercontent.com/shepilov-vladislav/fast-healthchecks/refs/heads/main/docs/img/green.svg\" width=\"30\"> <strong>FastHealthcheck</strong>\n</h1>\n\n<b>Framework agnostic health checks with integrations for most popular ASGI frameworks: [FastAPI](https://github.com/fastapi/fastapi) / [Faststream](https://github.com/airtai/faststream) / [Litestar](https://github.com/litestar-org/litestar) to help you to implement the [Health Check API](https://microservices.io/patterns/observability/health-check-api.html) pattern</b>\n\n---\n\n<p align=\"center\">\n\n  <a href=\"https://github.com/shepilov-vladislav/fast-healthchecks/actions/workflows/1_test.yml\" target=\"_blank\">\n    <img src=\"https://github.com/shepilov-vladislav/fast-healthchecks/actions/workflows/1_test.yml/badge.svg?branch=main\" alt=\"Test Passing\"/>\n  </a>\n\n  <a href=\"https://codecov.io/gh/shepilov-vladislav/fast-healthchecks\" target=\"_blank\">\n    <img src=\"https://codecov.io/gh/shepilov-vladislav/fast-healthchecks/branch/main/graph/badge.svg?token=ddDOL8qZLp\" alt=\"Coverage\"/>\n  </a>\n\n  <!-- <a href=\"https://www.pepy.tech/projects/fast-healthchecks\" target=\"_blank\">\n    <img src=\"https://static.pepy.tech/personalized-badge/fast-healthchecks?period=month&units=international_system&left_color=grey&right_color=green&left_text=downloads/month\" alt=\"Downloads\"/>\n  </a> -->\n\n  <a href=\"https://pypi.org/project/fast-healthchecks\" target=\"_blank\">\n    <img src=\"https://img.shields.io/pypi/v/fast-healthchecks?label=PyPI\" alt=\"Package version\"/>\n  </a>\n\n  <a href=\"https://pypi.org/project/fast-healthchecks\" target=\"_blank\">\n    <img src=\"https://img.shields.io/pypi/pyversions/fast-healthchecks.svg\" alt=\"Supported Python versions\"/>\n  </a>\n\n  <a href=\"https://github.com/shepilov-vladislav/fast-healthchecks/blob/main/LICENSE\" target=\"_blank\">\n    <img src=\"https://img.shields.io/github/license/shepilov-vladislav/fast-healthchecks.png\" alt=\"License\"/>\n  </a>\n\n<p>\n\n---\n\n## Installation\n\nWith `pip`:\n```bash\npip install fast-healthcheck\n```\n\nWith `poetry`:\n```bash\npoetry add fast-healthcheck\n```\n\nWith `uv`:\n```bash\nuv add fast-healthcheck\n```\n\n## Quick Start\n\nExamples:\n- [FastAPI example](./examples/fastapi_example)\n- [Faststream example](./examples/faststream_example)\n- [Litestar example](./examples/litestar_example)\n\n```python\nimport asyncio\nimport os\nimport time\n\nfrom fastapi import FastAPI\n\nfrom fast_healthchecks.checks.function import FunctionHealthCheck\nfrom fast_healthchecks.checks.kafka import KafkaHealthCheck\nfrom fast_healthchecks.checks.mongo import MongoHealthCheck\nfrom fast_healthchecks.checks.postgresql.asyncpg import PostgreSQLAsyncPGHealthCheck\nfrom fast_healthchecks.checks.postgresql.psycopg import PostgreSQLPsycopgHealthCheck\nfrom fast_healthchecks.checks.rabbitmq import RabbitMQHealthCheck\nfrom fast_healthchecks.checks.redis import RedisHealthCheck\nfrom fast_healthchecks.checks.url import UrlHealthCheck\nfrom fast_healthchecks.integrations.fastapi import HealthcheckRouter, Probe\n\n\ndef sync_dummy_check() -> bool:\n    time.sleep(0.1)\n    return True\n\n\nasync def async_dummy_check() -> bool:\n    await asyncio.sleep(0.1)\n    return True\n\n\napp = FastAPI()\napp.include_router(\n    HealthcheckRouter(\n        Probe(\n            name=\"liveness\",\n            checks=[\n                FunctionHealthCheck(func=sync_dummy_check, name=\"Sync dummy\"),\n            ],\n        ),\n        Probe(\n            name=\"readiness\",\n            checks=[\n                KafkaHealthCheck(\n                    bootstrap_servers=os.environ[\"KAFKA_BOOTSTRAP_SERVERS\"],\n                    name=\"Kafka\",\n                ),\n                MongoHealthCheck.from_dsn(os.environ[\"MONGO_DSN\"], name=\"Mongo\"),\n                PostgreSQLAsyncPGHealthCheck.from_dsn(os.environ[\"POSTGRES_DSN\"], name=\"PostgreSQL asyncpg\"),\n                PostgreSQLPsycopgHealthCheck.from_dsn(os.environ[\"POSTGRES_DSN\"], name=\"PostgreSQL psycopg\"),\n                RabbitMQHealthCheck.from_dsn(os.environ[\"RABBITMQ_DSN\"], name=\"RabbitMQ\"),\n                RedisHealthCheck.from_dsn(os.environ[\"REDIS_DSN\"], name=\"Redis\"),\n                UrlHealthCheck(url=\"https://httpbin.org/status/200\", name=\"URL 200\"),\n            ],\n        ),\n        Probe(\n            name=\"startup\",\n            checks=[\n                FunctionHealthCheck(func=async_dummy_check, name=\"Async dummy\"),\n            ],\n        ),\n        debug=True,\n        prefix=\"/health\",\n    ),\n)\n```\n\n## Development\n\n### Setup environment\n\n```bash\ngit clone https://github.com/shepilov-vladislav/fast-healthchecks.git\ncd fast-healthchecks\nuv sync --group=dev --group=docs --all-extras\n```\n\n### Run linters\n\n```bash\nmake lint\n```\n\n### Run all tests\n\n```bash\nmake tests-all\n```\n\n### Serve documentation\n\n```bash\nmake serve-docs\n```\n\n## Known alternatives\n\n- [FastAPI Health](https://github.com/Kludex/fastapi-health)\n- [FastAPI Health Monitor](https://github.com/adamkirchberger/fastapi-health-monitor)\n- [fastapi_healthz](https://github.com/matteocacciola/fastapi_healthz)\n- [fastapi_healthcheck](https://github.com/jtom38/fastapi_healthcheck)\n\n## License\n\nThis project is licensed under the terms of the MIT license.\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024 Vladislav Shepilov  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "FastHealthchecks",
    "version": "0.1.3",
    "project_urls": {
        "documentation": "https://shepilov-vladislav.github.io/fast-healthchecks/",
        "homepage": "https://github.com/shepilov-vladislav/fast-healthchecks",
        "source": "https://github.com/shepilov-vladislav/fast-healthchecks",
        "tracker": "https://github.com/shepilov-vladislav/fast-healthchecks/issues"
    },
    "split_keywords": [
        "healthcheck",
        " library",
        " fastapi",
        " starlette",
        " faststream",
        " litestar",
        " asyncpg",
        " psycopg",
        " redis",
        " aio-pika",
        " httpx",
        " aiokafka",
        " motor"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0772cd516c62bdec69abb154a48b550db2034c391ea2e34acfc4856bd3437cf9",
                "md5": "ce1fcd4ed5e895a83d49889a92dae6aa",
                "sha256": "e298d616afc6f1f7e19481d7ff75f15f2757eb1f00225b1e9e4a329cb2e7491e"
            },
            "downloads": -1,
            "filename": "fast_healthchecks-0.1.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ce1fcd4ed5e895a83d49889a92dae6aa",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0.0,>=3.10.0",
            "size": 27808,
            "upload_time": "2024-12-10T02:05:32",
            "upload_time_iso_8601": "2024-12-10T02:05:32.616340Z",
            "url": "https://files.pythonhosted.org/packages/07/72/cd516c62bdec69abb154a48b550db2034c391ea2e34acfc4856bd3437cf9/fast_healthchecks-0.1.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "10e97b0eab1f33d8e581bfa00f6414109b6266d50f171ced39e388e2eb53486a",
                "md5": "7d29fdece0d80d5a51deb7f459210349",
                "sha256": "f6073b54512b990e4eba05f6530470f0c27b9990398796878b94ebb00f456bd7"
            },
            "downloads": -1,
            "filename": "fast_healthchecks-0.1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "7d29fdece0d80d5a51deb7f459210349",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0.0,>=3.10.0",
            "size": 20485,
            "upload_time": "2024-12-10T02:05:35",
            "upload_time_iso_8601": "2024-12-10T02:05:35.173817Z",
            "url": "https://files.pythonhosted.org/packages/10/e9/7b0eab1f33d8e581bfa00f6414109b6266d50f171ced39e388e2eb53486a/fast_healthchecks-0.1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-10 02:05:35",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "shepilov-vladislav",
    "github_project": "fast-healthchecks",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "fast-healthchecks"
}
        
Elapsed time: 0.96531s