diff options
author | CoprDistGit <infra@openeuler.org> | 2023-05-18 05:57:15 +0000 |
---|---|---|
committer | CoprDistGit <infra@openeuler.org> | 2023-05-18 05:57:15 +0000 |
commit | b4e9b58a8c84d0d6c7b008095b793d396773eba9 (patch) | |
tree | 5d53f0f87b8c26d76b93c913a451f03cbbd1aad5 | |
parent | 25e58d8ee061009d0dd59f591d19ddecb5b07cc3 (diff) |
automatic import of python-aio-tiny-healthcheck
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | python-aio-tiny-healthcheck.spec | 453 | ||||
-rw-r--r-- | sources | 1 |
3 files changed, 455 insertions, 0 deletions
@@ -0,0 +1 @@ +/aio_tiny_healthcheck-1.1.2.tar.gz diff --git a/python-aio-tiny-healthcheck.spec b/python-aio-tiny-healthcheck.spec new file mode 100644 index 0000000..8a6687f --- /dev/null +++ b/python-aio-tiny-healthcheck.spec @@ -0,0 +1,453 @@ +%global _empty_manifest_terminate_build 0 +Name: python-aio-tiny-healthcheck +Version: 1.1.2 +Release: 1 +Summary: Tiny asynchronous implementation of healthcheck provider and http-server +License: Apache Software License +URL: https://github.com/nabrosimoff/aio_tiny_healthcheck +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/01/a6/b58735ef01f8a30f52ce5146c9b185c08a52706b373c8074dcb601053d97/aio_tiny_healthcheck-1.1.2.tar.gz +BuildArch: noarch + + +%description +# aio_tiny_healthcheck +[](https://github.com/nabrosimoff/aio_tiny_healthcheck) +[](https://travis-ci.org/nabrosimoff/aio_tiny_healthcheck) +[](https://travis-ci.org/nabrosimoff/aio_tiny_healthcheck) + +Tiny asynchronous implementation of healthcheck provider and server + +# Installation + +```bash +pip install aio-tiny-healthcheck +``` + +# Usage +By default, the Checker returns 200 if all checks successfully finish or 500 in opposite case. + +## Using with aiohttp +```python +from aiohttp import web + +from aio_tiny_healthcheck.checker import Checker + +def some_sync_check(): + return True + +async def some_async_check(): + return False + +healthcheck_provider = Checker() +healthcheck_provider.add_check('sync_check_true', some_async_check) +healthcheck_provider.add_check('async_check_false', some_async_check) + + +app = web.Application() +app.router.add_get('/healthcheck', healthcheck_provider.aiohttp_handler) +web.run_app(app) +``` + +## Using with Sanic +```python +from sanic import Sanic +from sanic.response import json +from aio_tiny_healthcheck.checker import Checker + +app = Sanic() + +def some_sync_check(): + return True + +async def some_async_check(): + return False + +healthcheck_provider = Checker(success_code=201, fail_code=400) +healthcheck_provider.add_check('sync_check_true', some_async_check) +healthcheck_provider.add_check('async_check_false', some_async_check) + +@app.route("/healthcheck") +async def test(request): + hc_response = healthcheck_provider.check_handler() + return json(hc_response.body, status=hc_response.code) + +if __name__ == "__main__": + app.run(host="0.0.0.0", port=8000) +``` + +## Using in concurrent mode +You should want to run healthcheck in background if you already have some blocking operation in your execution flow. +So, you can just use built-in server for this. + +```python +from aio_tiny_healthcheck.checker import Checker +from aio_tiny_healthcheck.http_server import HttpServer +import asyncio + + +async def some_long_task(): + await asyncio.sleep(3600) + + +def some_sync_check(): + return True + + +async def some_async_check(): + return True + + +aio_thc = Checker() +hc_server = HttpServer( + aio_thc, + path='/health', + host='localhost', + port=9090 +) + +aio_thc.add_check('sync_check_true', some_async_check) +aio_thc.add_check('async_check_false', some_async_check) + + +async def main(): + # Run healthcheck concurrently + asyncio.create_task(hc_server.run()) + + # Run long task + await some_long_task() + + +if __name__ == '__main__': + loop = asyncio.get_event_loop() + loop.run_until_complete(main()) + +``` + +## Utility for health checking + +``` +python -m aio_tiny_healthcheck http://localhost:9192/healthcheck +``` + +Useful for running health check without external dependencies like curl. + +By default, concurrent server and health checking utility are working +with a port and query path `http://localhost:8000/healthcheck`. +So, if you run concurrent server with no using arguments, you can also run the utility +with without arguments `python -m aio_tiny_healthcheck`. + + + + +%package -n python3-aio-tiny-healthcheck +Summary: Tiny asynchronous implementation of healthcheck provider and http-server +Provides: python-aio-tiny-healthcheck +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-aio-tiny-healthcheck +# aio_tiny_healthcheck +[](https://github.com/nabrosimoff/aio_tiny_healthcheck) +[](https://travis-ci.org/nabrosimoff/aio_tiny_healthcheck) +[](https://travis-ci.org/nabrosimoff/aio_tiny_healthcheck) + +Tiny asynchronous implementation of healthcheck provider and server + +# Installation + +```bash +pip install aio-tiny-healthcheck +``` + +# Usage +By default, the Checker returns 200 if all checks successfully finish or 500 in opposite case. + +## Using with aiohttp +```python +from aiohttp import web + +from aio_tiny_healthcheck.checker import Checker + +def some_sync_check(): + return True + +async def some_async_check(): + return False + +healthcheck_provider = Checker() +healthcheck_provider.add_check('sync_check_true', some_async_check) +healthcheck_provider.add_check('async_check_false', some_async_check) + + +app = web.Application() +app.router.add_get('/healthcheck', healthcheck_provider.aiohttp_handler) +web.run_app(app) +``` + +## Using with Sanic +```python +from sanic import Sanic +from sanic.response import json +from aio_tiny_healthcheck.checker import Checker + +app = Sanic() + +def some_sync_check(): + return True + +async def some_async_check(): + return False + +healthcheck_provider = Checker(success_code=201, fail_code=400) +healthcheck_provider.add_check('sync_check_true', some_async_check) +healthcheck_provider.add_check('async_check_false', some_async_check) + +@app.route("/healthcheck") +async def test(request): + hc_response = healthcheck_provider.check_handler() + return json(hc_response.body, status=hc_response.code) + +if __name__ == "__main__": + app.run(host="0.0.0.0", port=8000) +``` + +## Using in concurrent mode +You should want to run healthcheck in background if you already have some blocking operation in your execution flow. +So, you can just use built-in server for this. + +```python +from aio_tiny_healthcheck.checker import Checker +from aio_tiny_healthcheck.http_server import HttpServer +import asyncio + + +async def some_long_task(): + await asyncio.sleep(3600) + + +def some_sync_check(): + return True + + +async def some_async_check(): + return True + + +aio_thc = Checker() +hc_server = HttpServer( + aio_thc, + path='/health', + host='localhost', + port=9090 +) + +aio_thc.add_check('sync_check_true', some_async_check) +aio_thc.add_check('async_check_false', some_async_check) + + +async def main(): + # Run healthcheck concurrently + asyncio.create_task(hc_server.run()) + + # Run long task + await some_long_task() + + +if __name__ == '__main__': + loop = asyncio.get_event_loop() + loop.run_until_complete(main()) + +``` + +## Utility for health checking + +``` +python -m aio_tiny_healthcheck http://localhost:9192/healthcheck +``` + +Useful for running health check without external dependencies like curl. + +By default, concurrent server and health checking utility are working +with a port and query path `http://localhost:8000/healthcheck`. +So, if you run concurrent server with no using arguments, you can also run the utility +with without arguments `python -m aio_tiny_healthcheck`. + + + + +%package help +Summary: Development documents and examples for aio-tiny-healthcheck +Provides: python3-aio-tiny-healthcheck-doc +%description help +# aio_tiny_healthcheck +[](https://github.com/nabrosimoff/aio_tiny_healthcheck) +[](https://travis-ci.org/nabrosimoff/aio_tiny_healthcheck) +[](https://travis-ci.org/nabrosimoff/aio_tiny_healthcheck) + +Tiny asynchronous implementation of healthcheck provider and server + +# Installation + +```bash +pip install aio-tiny-healthcheck +``` + +# Usage +By default, the Checker returns 200 if all checks successfully finish or 500 in opposite case. + +## Using with aiohttp +```python +from aiohttp import web + +from aio_tiny_healthcheck.checker import Checker + +def some_sync_check(): + return True + +async def some_async_check(): + return False + +healthcheck_provider = Checker() +healthcheck_provider.add_check('sync_check_true', some_async_check) +healthcheck_provider.add_check('async_check_false', some_async_check) + + +app = web.Application() +app.router.add_get('/healthcheck', healthcheck_provider.aiohttp_handler) +web.run_app(app) +``` + +## Using with Sanic +```python +from sanic import Sanic +from sanic.response import json +from aio_tiny_healthcheck.checker import Checker + +app = Sanic() + +def some_sync_check(): + return True + +async def some_async_check(): + return False + +healthcheck_provider = Checker(success_code=201, fail_code=400) +healthcheck_provider.add_check('sync_check_true', some_async_check) +healthcheck_provider.add_check('async_check_false', some_async_check) + +@app.route("/healthcheck") +async def test(request): + hc_response = healthcheck_provider.check_handler() + return json(hc_response.body, status=hc_response.code) + +if __name__ == "__main__": + app.run(host="0.0.0.0", port=8000) +``` + +## Using in concurrent mode +You should want to run healthcheck in background if you already have some blocking operation in your execution flow. +So, you can just use built-in server for this. + +```python +from aio_tiny_healthcheck.checker import Checker +from aio_tiny_healthcheck.http_server import HttpServer +import asyncio + + +async def some_long_task(): + await asyncio.sleep(3600) + + +def some_sync_check(): + return True + + +async def some_async_check(): + return True + + +aio_thc = Checker() +hc_server = HttpServer( + aio_thc, + path='/health', + host='localhost', + port=9090 +) + +aio_thc.add_check('sync_check_true', some_async_check) +aio_thc.add_check('async_check_false', some_async_check) + + +async def main(): + # Run healthcheck concurrently + asyncio.create_task(hc_server.run()) + + # Run long task + await some_long_task() + + +if __name__ == '__main__': + loop = asyncio.get_event_loop() + loop.run_until_complete(main()) + +``` + +## Utility for health checking + +``` +python -m aio_tiny_healthcheck http://localhost:9192/healthcheck +``` + +Useful for running health check without external dependencies like curl. + +By default, concurrent server and health checking utility are working +with a port and query path `http://localhost:8000/healthcheck`. +So, if you run concurrent server with no using arguments, you can also run the utility +with without arguments `python -m aio_tiny_healthcheck`. + + + + +%prep +%autosetup -n aio-tiny-healthcheck-1.1.2 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-aio-tiny-healthcheck -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Thu May 18 2023 Python_Bot <Python_Bot@openeuler.org> - 1.1.2-1 +- Package Spec generated @@ -0,0 +1 @@ +02b55c06a5e80826012f19b9313d5638 aio_tiny_healthcheck-1.1.2.tar.gz |