Skip to content

Commit

Permalink
docs(all): added README.md, LICENSE and CHANGELOG.md
Browse files Browse the repository at this point in the history
  • Loading branch information
shepilov-vladislav committed Dec 9, 2024
0 parents commit 5840e00
Show file tree
Hide file tree
Showing 3 changed files with 179 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
## v0.0.0 (2024-12-10)
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
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.
157 changes: 157 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
<h1 align="center" style="vertical-align: middle;">
<img src="./docs/img/logo.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/airtai/fast-healthchecks/blob/main/LICENSE" target="_blank">
<img src="https://img.shields.io/github/license/airtai/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
```

## License

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

0 comments on commit 5840e00

Please sign in to comment.