Skip to main content

FastHealthchecks

Project description

FastHealthcheck

Framework agnostic health checks with integrations for most popular ASGI frameworks: FastAPI / Faststream / Litestar to help you to implement the Health Check API pattern


Test Passing Coverage Downloads Package version Supported Python versions License


Installation

With pip:

pip install fast-healthchecks

With poetry:

poetry add fast-healthchecks

With uv:

uv add fast-healthchecks

Quick Start

Examples:

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://httpbingo.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

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

Run linters

make lint

Run all tests

make tests-all

Serve documentation

make serve-docs

Known alternatives

License

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

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

fast_healthchecks-0.2.4.tar.gz (22.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fast_healthchecks-0.2.4-py3-none-any.whl (31.0 kB view details)

Uploaded Python 3

File details

Details for the file fast_healthchecks-0.2.4.tar.gz.

File metadata

  • Download URL: fast_healthchecks-0.2.4.tar.gz
  • Upload date:
  • Size: 22.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fast_healthchecks-0.2.4.tar.gz
Algorithm Hash digest
SHA256 5c3c08f6725a45921d543ae9d5bb9323e283a7de0226f0f2cc085b450392d044
MD5 27c93beb1b74084541adddbd92e17025
BLAKE2b-256 dc67ca837c9a6e6b45d7565820ccf4f13b7b3d224b72255972c3a2bdef221b34

See more details on using hashes here.

Provenance

The following attestation bundles were made for fast_healthchecks-0.2.4.tar.gz:

Publisher: 4_pythonpublish.yaml on shepilov-vladislav/fast-healthchecks

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fast_healthchecks-0.2.4-py3-none-any.whl.

File metadata

File hashes

Hashes for fast_healthchecks-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 04a1aa4aaf0b29c604d5f8529aa75e41d581e157c4a46041d9c3d577844b8a79
MD5 cb98f739705f0800c342e1e8efbf1fe4
BLAKE2b-256 648a437ecf013aa150db6122071d7cd10722f3d966ebc9c68c8797ed70532804

See more details on using hashes here.

Provenance

The following attestation bundles were made for fast_healthchecks-0.2.4-py3-none-any.whl:

Publisher: 4_pythonpublish.yaml on shepilov-vladislav/fast-healthchecks

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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