Name | orloj JSON |
Version |
0.1.3
JSON |
| download |
home_page | None |
Summary | Scheduler middleware for ASGI frameworks |
upload_time | 2024-05-17 07:43:42 |
maintainer | None |
docs_url | None |
author | Sitt Guruvanich |
requires_python | <4.0,>=3.8 |
license | MIT |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Orloj
[![Format](https://img.shields.io/pypi/format/orloj)](https://pypi.org/project/orloj)
[![Python version](https://img.shields.io/pypi/pyversions/orloj)](https://pypi.org/project/orloj)
[![License](https://img.shields.io/pypi/l/orloj)](https://pypi.org/project/orloj)
[![Top](https://img.shields.io/github/languages/top/aekasitt/orloj)](.)
[![Languages](https://img.shields.io/github/languages/count/aekasitt/orloj)](.)
[![Size](https://img.shields.io/github/repo-size/aekasitt/orloj)](.)
[![Last commit](https://img.shields.io/github/last-commit/aekasitt/orloj/master)](.)
[![Orloj banner](static/orloj-banner.svg)](static/orloj-banner.svg)
## Getting started
You can use `orloj` simply by installing via `pip` on your Terminal.
```sh
pip install orloj
```
or alternatively when using [poetry](https://python-poetry.org) package manager as such:
```sh
poetry add orloj
```
And then you can begin using `OrlojMiddleware` in your ASGI project as such
```python
...
from orloj import OrlojMiddleware
def action() -> None:
"""Action to be called by scheduler"""
app.add_middleware(OrlojMiddleware, interval=3, job=action) # Schedules for 3 second interval
...
```
The following example shows you how to setup `OrlojMiddleware` to run scheduled tasks alongside
your [FastAPI](https://github.com/tiangolo/fastapi) application.
```python
from fastapi import FastAPI
from logging import Logger, getLogger
from orloj import OrlojMiddleware
from starlette.responses import PlainTextResponse, RedirectResponse
app = FastAPI()
logger: Logger = getLogger("uvicorn")
def hello_name(name: str) -> None:
logger.info(f"Hello, {name}!")
def hello_world() -> None:
logger.info("Hello, World!")
@app.get("/")
async def redirect_to_swagger_docs() -> RedirectResponse:
"""Redirects to swagger documentation
"""
return RedirectResponse("/docs")
@app.get("/health", response_class=PlainTextResponse, status_code=200)
async def health() -> str:
"""Health check
"""
return "OK"
app.add_middleware(OrlojMiddleware, interval=3, job=hello_name, name="Igor")
app.add_middleware(OrlojMiddleware, interval=6, job=hello_world)
```
## Dependencies
* [APScheduler](https://github.com/agronholm/apscheduler)
[![PyPI](https://img.shields.io/badge/PyPI-3775A9?logo=pypi&logoColor=white)](https://pypi.org/project/APScheduler)
[![Docs](https://img.shields.io/readthedocs/apscheduler?logo=readthedocs)](https://apscheduler.readthedocs.io/en/3.x)
* [starlette](https://www.starlette.io)
[![PyPI](https://img.shields.io/badge/PyPI-3775A9?logo=pypi&logoColor=white)](https://pypi.org/project/starlette)
[![Docs](https://img.shields.io/badge/MkDocs-526CFE?logo=materialformkdocs&logoColor=white)](https://www.starlette.io)
## Contributions
To contribute to the project, fork the repository and clone to your local device and development
dependencies including three extra libraries not included in final builds as such:
* [black](https://github.com/psf/black) - The uncompromising Python code formatter
* [mypy](https://github.com/python/mypy) - Optional static typing for Python
* [pytest](https://github.com/pytest-dev/pytest) - The pytest framework makes it easy to write small tests, yet scales to support complex functional testing
Use the following commands to setup your local environment with development dependencies:
```bash
pip install --user poetry
poetry install --with dev
```
## Acknowledgements
* [APScheduler Web Examples](https://github.com/agronholm/apscheduler/tree/master/examples/web)
* [Wikimedia Commons - File:Prague Astronomical Clock.svg](https://commons.wikimedia.org/wiki/File:Prague_Astronomical_Clock.svg)
## License
This project is licensed under the terms of the MIT license.
Raw data
{
"_id": null,
"home_page": null,
"name": "orloj",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.8",
"maintainer_email": null,
"keywords": null,
"author": "Sitt Guruvanich",
"author_email": "aekazitt+github@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/3d/b1/6918240e990ab75965ef68e26fc0534bbe1f169324e36f6f9507eab7864a/orloj-0.1.3.tar.gz",
"platform": null,
"description": "# Orloj\n\n[![Format](https://img.shields.io/pypi/format/orloj)](https://pypi.org/project/orloj)\n[![Python version](https://img.shields.io/pypi/pyversions/orloj)](https://pypi.org/project/orloj)\n[![License](https://img.shields.io/pypi/l/orloj)](https://pypi.org/project/orloj)\n[![Top](https://img.shields.io/github/languages/top/aekasitt/orloj)](.)\n[![Languages](https://img.shields.io/github/languages/count/aekasitt/orloj)](.)\n[![Size](https://img.shields.io/github/repo-size/aekasitt/orloj)](.)\n[![Last commit](https://img.shields.io/github/last-commit/aekasitt/orloj/master)](.)\n\n[![Orloj banner](static/orloj-banner.svg)](static/orloj-banner.svg)\n\n## Getting started\n\nYou can use `orloj` simply by installing via `pip` on your Terminal.\n\n```sh\npip install orloj\n```\n\nor alternatively when using [poetry](https://python-poetry.org) package manager as such:\n\n```sh\npoetry add orloj\n```\n\nAnd then you can begin using `OrlojMiddleware` in your ASGI project as such\n\n```python\n...\nfrom orloj import OrlojMiddleware\n\ndef action() -> None:\n \"\"\"Action to be called by scheduler\"\"\"\n\napp.add_middleware(OrlojMiddleware, interval=3, job=action) # Schedules for 3 second interval\n...\n```\n\nThe following example shows you how to setup `OrlojMiddleware` to run scheduled tasks alongside\nyour [FastAPI](https://github.com/tiangolo/fastapi) application.\n\n```python\nfrom fastapi import FastAPI\nfrom logging import Logger, getLogger\nfrom orloj import OrlojMiddleware\nfrom starlette.responses import PlainTextResponse, RedirectResponse\n\napp = FastAPI()\nlogger: Logger = getLogger(\"uvicorn\")\n\ndef hello_name(name: str) -> None:\n logger.info(f\"Hello, {name}!\")\n\ndef hello_world() -> None:\n logger.info(\"Hello, World!\")\n\n@app.get(\"/\")\nasync def redirect_to_swagger_docs() -> RedirectResponse:\n \"\"\"Redirects to swagger documentation\n \"\"\"\n return RedirectResponse(\"/docs\")\n\n@app.get(\"/health\", response_class=PlainTextResponse, status_code=200)\nasync def health() -> str:\n \"\"\"Health check\n \"\"\"\n return \"OK\"\n\napp.add_middleware(OrlojMiddleware, interval=3, job=hello_name, name=\"Igor\")\napp.add_middleware(OrlojMiddleware, interval=6, job=hello_world)\n```\n\n## Dependencies\n\n* [APScheduler](https://github.com/agronholm/apscheduler)\n [![PyPI](https://img.shields.io/badge/PyPI-3775A9?logo=pypi&logoColor=white)](https://pypi.org/project/APScheduler)\n [![Docs](https://img.shields.io/readthedocs/apscheduler?logo=readthedocs)](https://apscheduler.readthedocs.io/en/3.x)\n\n* [starlette](https://www.starlette.io)\n [![PyPI](https://img.shields.io/badge/PyPI-3775A9?logo=pypi&logoColor=white)](https://pypi.org/project/starlette)\n [![Docs](https://img.shields.io/badge/MkDocs-526CFE?logo=materialformkdocs&logoColor=white)](https://www.starlette.io)\n\n## Contributions\n\nTo contribute to the project, fork the repository and clone to your local device and development\ndependencies including three extra libraries not included in final builds as such:\n\n* [black](https://github.com/psf/black) - The uncompromising Python code formatter \n* [mypy](https://github.com/python/mypy) - Optional static typing for Python\n* [pytest](https://github.com/pytest-dev/pytest) - The pytest framework makes it easy to write small tests, yet scales to support complex functional testing\n\nUse the following commands to setup your local environment with development dependencies:\n\n```bash\npip install --user poetry\npoetry install --with dev\n```\n\n## Acknowledgements\n\n* [APScheduler Web Examples](https://github.com/agronholm/apscheduler/tree/master/examples/web)\n* [Wikimedia Commons - File:Prague Astronomical Clock.svg](https://commons.wikimedia.org/wiki/File:Prague_Astronomical_Clock.svg)\n\n## License\n\nThis project is licensed under the terms of the MIT license.",
"bugtrack_url": null,
"license": "MIT",
"summary": "Scheduler middleware for ASGI frameworks",
"version": "0.1.3",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "c0e4c4881e0dd8405a91c1fc3719106cd4faec25f06f5cab85e5b2930f0393b8",
"md5": "53ef80dc44382073509bc759d2018774",
"sha256": "0ae21cb86854e23fffb5a5ffaad17d6f6c8e93f70b5d7862d6385c22103176c4"
},
"downloads": -1,
"filename": "orloj-0.1.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "53ef80dc44382073509bc759d2018774",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.8",
"size": 4594,
"upload_time": "2024-05-17T07:43:41",
"upload_time_iso_8601": "2024-05-17T07:43:41.007951Z",
"url": "https://files.pythonhosted.org/packages/c0/e4/c4881e0dd8405a91c1fc3719106cd4faec25f06f5cab85e5b2930f0393b8/orloj-0.1.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3db16918240e990ab75965ef68e26fc0534bbe1f169324e36f6f9507eab7864a",
"md5": "17b31627b6c46b1197dfff4fb9625165",
"sha256": "ccfcb93c0818b834289d579dccf138ae609cef8104d16c1090a13c5363e04745"
},
"downloads": -1,
"filename": "orloj-0.1.3.tar.gz",
"has_sig": false,
"md5_digest": "17b31627b6c46b1197dfff4fb9625165",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.8",
"size": 3951,
"upload_time": "2024-05-17T07:43:42",
"upload_time_iso_8601": "2024-05-17T07:43:42.197324Z",
"url": "https://files.pythonhosted.org/packages/3d/b1/6918240e990ab75965ef68e26fc0534bbe1f169324e36f6f9507eab7864a/orloj-0.1.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-17 07:43:42",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "orloj"
}