Name | probirka JSON |
Version |
0.3.1
JSON |
| download |
home_page | None |
Summary | Python 3 library to write simple asynchronous health checks (probes) |
upload_time | 2025-01-01 17:42:46 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.8 |
license | None |
keywords |
health-check
monitoring
probes
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# PROB🧪RKA
Python 3 library to write simple asynchronous health checks (probes).
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![PyPI](https://img.shields.io/pypi/v/probirka.svg)](https://pypi.python.org/pypi/probirka)
[![PyPI](https://img.shields.io/pypi/dm/probirka.svg)](https://pypi.python.org/pypi/probirka)
## Overview
Probirka is a Python library designed to facilitate the creation of simple asynchronous health checks, also known as probes. It allows you to define custom probes to monitor the health of various services and components in your application.
## Installation
Install Probirka using pip:
```shell
pip install probirka
```
## Usage
Here is a simple example of how to use Probirka to create an asynchronous health check:
```python
import asyncio
from probirka import Probe, HealthCheck
class DatabaseProbe(Probe):
async def check(self):
# Simulate a database check
await asyncio.sleep(1)
return True
class CacheProbe(Probe):
async def check(self):
# Simulate a cache check
await asyncio.sleep(1)
return True
async def main():
health_check = HealthCheck(probes=[DatabaseProbe(), CacheProbe()])
results = await health_check.run()
print(results)
if __name__ == "__main__":
asyncio.run(main())
```
This example defines two probes, `DatabaseProbe` and `CacheProbe`, and runs them as part of a health check.
## Integration with FastAPI
You can integrate Probirka with FastAPI as follows:
```python
from fastapi import FastAPI
from probirka import Probirka
from probirka._fastapi import make_fastapi_endpoint
app = FastAPI()
probirka_instance = Probirka()
fastapi_endpoint = make_fastapi_endpoint(probirka_instance)
app.add_api_route("/run", fastapi_endpoint)
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=8000)
```
## Integration with aiohttp
You can integrate Probirka with aiohttp as follows:
```python
from aiohttp import web
from probirka import Probirka
async def aiohttp_handler(request):
probirka_instance = Probirka()
res = await probirka_instance.run()
return web.json_response(res)
app = web.Application()
app.router.add_get('/run', aiohttp_handler)
if __name__ == '__main__':
web.run_app(app)
```
## Contributing
Contributions are welcome! Please open an issue or submit a pull request on GitHub.
## License
This project is licensed under the MIT License.
Raw data
{
"_id": null,
"home_page": null,
"name": "probirka",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "health-check, monitoring, probes",
"author": null,
"author_email": "KODE <slurm@kode.ru>",
"download_url": "https://files.pythonhosted.org/packages/04/58/7568c36889a938db3cdaee8aec0cb19e73b94289d6b0a08e07dcd55b96ef/probirka-0.3.1.tar.gz",
"platform": null,
"description": "# PROB\ud83e\uddeaRKA\n\nPython 3 library to write simple asynchronous health checks (probes).\n\n[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)\n[![PyPI](https://img.shields.io/pypi/v/probirka.svg)](https://pypi.python.org/pypi/probirka)\n[![PyPI](https://img.shields.io/pypi/dm/probirka.svg)](https://pypi.python.org/pypi/probirka)\n\n## Overview\n\nProbirka is a Python library designed to facilitate the creation of simple asynchronous health checks, also known as probes. It allows you to define custom probes to monitor the health of various services and components in your application.\n\n## Installation\n\nInstall Probirka using pip:\n\n```shell\npip install probirka\n```\n\n## Usage\n\nHere is a simple example of how to use Probirka to create an asynchronous health check:\n\n```python\nimport asyncio\nfrom probirka import Probe, HealthCheck\n\nclass DatabaseProbe(Probe):\n async def check(self):\n # Simulate a database check\n await asyncio.sleep(1)\n return True\n\nclass CacheProbe(Probe):\n async def check(self):\n # Simulate a cache check\n await asyncio.sleep(1)\n return True\n\nasync def main():\n health_check = HealthCheck(probes=[DatabaseProbe(), CacheProbe()])\n results = await health_check.run()\n print(results)\n\nif __name__ == \"__main__\":\n asyncio.run(main())\n```\n\nThis example defines two probes, `DatabaseProbe` and `CacheProbe`, and runs them as part of a health check.\n\n## Integration with FastAPI\n\nYou can integrate Probirka with FastAPI as follows:\n\n```python\nfrom fastapi import FastAPI\nfrom probirka import Probirka\nfrom probirka._fastapi import make_fastapi_endpoint\n\napp = FastAPI()\n\nprobirka_instance = Probirka()\nfastapi_endpoint = make_fastapi_endpoint(probirka_instance)\n\napp.add_api_route(\"/run\", fastapi_endpoint)\n\nif __name__ == \"__main__\":\n import uvicorn\n uvicorn.run(app, host=\"0.0.0.0\", port=8000)\n```\n\n## Integration with aiohttp\n\nYou can integrate Probirka with aiohttp as follows:\n\n```python\nfrom aiohttp import web\nfrom probirka import Probirka\n\nasync def aiohttp_handler(request):\n probirka_instance = Probirka()\n res = await probirka_instance.run()\n return web.json_response(res)\n\napp = web.Application()\napp.router.add_get('/run', aiohttp_handler)\n\nif __name__ == '__main__':\n web.run_app(app)\n```\n\n## Contributing\n\nContributions are welcome! Please open an issue or submit a pull request on GitHub.\n\n## License\n\nThis project is licensed under the MIT License.\n",
"bugtrack_url": null,
"license": null,
"summary": "Python 3 library to write simple asynchronous health checks (probes)",
"version": "0.3.1",
"project_urls": {
"Repository": "https://github.com/appKODE/probirka"
},
"split_keywords": [
"health-check",
" monitoring",
" probes"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "ad6c0cbc8984d0c4086755fc7e5b25fbb18b82b1b1205c0ba08f110baf2e93ba",
"md5": "5e845b3e29f58f8246a932a068f07fd8",
"sha256": "932f67932ad219aa294451b126ad0ae9a1917cefb87fade1b16b53809406dcfb"
},
"downloads": -1,
"filename": "probirka-0.3.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "5e845b3e29f58f8246a932a068f07fd8",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 7777,
"upload_time": "2025-01-01T17:42:43",
"upload_time_iso_8601": "2025-01-01T17:42:43.325113Z",
"url": "https://files.pythonhosted.org/packages/ad/6c/0cbc8984d0c4086755fc7e5b25fbb18b82b1b1205c0ba08f110baf2e93ba/probirka-0.3.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "04587568c36889a938db3cdaee8aec0cb19e73b94289d6b0a08e07dcd55b96ef",
"md5": "7e178c1c7e2a2eaed1bb39ffce524795",
"sha256": "b0efbf0f04cd148fd5994389634e038117e5090cd360ca32e2894b49a6b49f7f"
},
"downloads": -1,
"filename": "probirka-0.3.1.tar.gz",
"has_sig": false,
"md5_digest": "7e178c1c7e2a2eaed1bb39ffce524795",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 119429,
"upload_time": "2025-01-01T17:42:46",
"upload_time_iso_8601": "2025-01-01T17:42:46.410737Z",
"url": "https://files.pythonhosted.org/packages/04/58/7568c36889a938db3cdaee8aec0cb19e73b94289d6b0a08e07dcd55b96ef/probirka-0.3.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-01 17:42:46",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "appKODE",
"github_project": "probirka",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "probirka"
}