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, job_id="scheduled-action")
...

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, job_id="hello-igor", name="Igor"
)
app.add_middleware(
  OrlojMiddleware, interval=6, job=hello_world, job_id="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:

  • mypy - Optional static typing for Python
  • pytest - The pytest framework makes it easy to write small tests, yet scales to support complex functional testing
  • ruff - An extremely fast Python linter and code formatter, written in Rust.

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.

Release files for orloj 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for orloj 0.1.4
File Size Uploaded
orloj-0.1.4.tar.gz 4.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for orloj 0.1.4
File Interpreter ABI Platform
orloj-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 9.2 kB

Release files / orloj-0.1.4.tar.gz

Download URL orloj-0.1.4.tar.gz
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
56c466eb1c3f9dd4554c3c5af8edc1f4ae06be891bfdc0ad9c30c010548eb0a6
BLAKE2b-256 checksum
How to use checksums
af097aa45b012a983ea72d422c7a60b1353b33e75351d3f906e412a8045bbac0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.12.0 Darwin/22.1.0

Release files / orloj-0.1.4-py3-none-any.whl

Download URL orloj-0.1.4-py3-none-any.whl
Size 4.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1d65f21de6e53dd79117e42a633745f6b6b943f8cfd9871247e6b12aee37d8ac
BLAKE2b-256 checksum
How to use checksums
4d56a5e0ebae2a3c90f3bd160eaa068e6ce448ac3a05bc22b840372937b5d1ab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.12.0 Darwin/22.1.0

Release history Release notifications | RSS feed

This release

0.1.4 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release 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