Skip to main content

Orloj

Format Python version License Top Languages Size Last commit

Orloj banner

Getting started

You can use orloj simply by installing via pip on your Terminal.

pip install orloj

or alternatively when using poetry package manager as such:

poetry add orloj

And then you can begin using OrlojMiddleware in your ASGI project as such

...
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 application.

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

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 - The uncompromising Python code formatter
  • mypy - Optional static typing for Python
  • 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:

pip install --user poetry
poetry install --with dev

Acknowledgements

License

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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

orloj-0.1.2.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

orloj-0.1.2-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file orloj-0.1.2.tar.gz.

File metadata

  • Download URL: orloj-0.1.2.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.0 Darwin/22.1.0

File hashes

Hashes for orloj-0.1.2.tar.gz
Algorithm Hash digest
SHA256 ec560b06bec6ebe884b14a550ffac813b7d3fbd322b5377575ae524d797dc0a7
MD5 fda2c1f48b50773ce9f8c2bf4450ce74
BLAKE2b-256 63021dce52ef8648e2898815ecb374608475a9c39f91cc838cee08aaed0923c1

See more details on using hashes here.

File details

Details for the file orloj-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: orloj-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.0 Darwin/22.1.0

File hashes

Hashes for orloj-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 196b11bf4d3bf7a10a1d56b3db7387c01235ebe2d510a18cea6b57937ffefd60
MD5 5f6a8e91e59a55749d2b9d8397275c39
BLAKE2b-256 ea505c48c42ba1e2da15c604b67a9d347cca466ce2d3c68fc604ec7a58fac503

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.4

2 files

0.1.3

2 files

This release

0.1.2 This release

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page