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.3.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.3-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: orloj-0.1.3.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.3.tar.gz
Algorithm Hash digest
SHA256 ccfcb93c0818b834289d579dccf138ae609cef8104d16c1090a13c5363e04745
MD5 17b31627b6c46b1197dfff4fb9625165
BLAKE2b-256 3db16918240e990ab75965ef68e26fc0534bbe1f169324e36f6f9507eab7864a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: orloj-0.1.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0ae21cb86854e23fffb5a5ffaad17d6f6c8e93f70b5d7862d6385c22103176c4
MD5 53ef80dc44382073509bc759d2018774
BLAKE2b-256 c0e4c4881e0dd8405a91c1fc3719106cd4faec25f06f5cab85e5b2930f0393b8

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.4

2 files

This release

0.1.3 This release

2 files

0.1.2

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