Metadata-Version: 2.4
Name: AppChecker
Version: 0.1.4
Summary: Adds healthcheck for PythonApp
Author: Sov Bur
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: asyncpg>=0.30.0
Requires-Dist: build>=1.2.2.post1
Requires-Dist: halo>=0.0.31
Requires-Dist: httpx>=0.28.1
Requires-Dist: pytest>=8.3.5
Requires-Dist: pytest-asyncio>=0.26.0
Dynamic: author
Dynamic: license-file
Dynamic: requires-python

# AppChecker

`AppChecker` is an asynchronous tool for performing application health checks during startup. It can be particularly useful in applications like FastAPI, where it helps confirm that your dependencies are running and operational, including database access, RabbitMQ connectivity, and that your application is ready to respond to HTTP requests. 

With `AppChecker`, you can easily register health check functions and manage their execution, making it a great fit for microservices and other applications that require health checks.

## Installation

You can install `AppChecker` using pip:

```bash
pip install appchecker
```

using uv:

```bash
uv add appchecker
```

## Example Usage
Each custom health check function, such as `check_cache`, should return either `True` for a successful check or `False` for a failed check. Here’s an example of how to use AppChecker for checking your application:

```python
import asyncio
from appchecker import AppChecker  # Import the AppChecker

# Create an instance of AppChecker
app_checker = AppChecker()

@app_checker.check_health
async def check_cache():
    await asyncio.sleep(2)  # Simulate the time taken to perform the check
    return True  # Successful check

async def main():
    await app_checker.run_checks()  # Run all checks

if __name__ == "__main__":
    asyncio.run(main())  # Start the asyncio event loop
```

## Example Output

When you run your checks, you’ll see output similar to this in the console:
```bash
---------------------------------------------------------------------------
                              check starts
---------------------------------------------------------------------------
collected 1 items

Starting check_cache...
✔ [SUCCESS] check_cache
---------------------------------------------------------------------------
                              1 [success]
---------------------------------------------------------------------------
All checks success.
```

## How It Works

AppChecker allows you to register health check functions using the check_health decorator. Each health check function should be asynchronous and return a result (e.g., True for a successful check or raise an exception for a failed check).

When you call app_checker.run_checks(), all registered functions are invoked in sequence, and the results are displayed on the screen.

## Features

- Asynchronous: Uses asynchronous functions for checks, which do not block the main execution flow.
- Flexibility: Easily add new checks by wrapping them in the decorator.
- Result Display: Conveniently displays the results of checks, including successful and failed checks.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Contribution

If you have suggestions for improving AppChecker, feel free to create a Pull Request or open Issues in the repository.
