Name | fast-priority JSON |
Version |
0.0.14
JSON |
| download |
home_page | None |
Summary | Simple and streigt forward priority queing gateway using fastapi |
upload_time | 2025-02-22 13:22:08 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.12 |
license | None |
keywords |
queue
fastapi
priority
redis
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# 🚀 Fast Priority Queue 🔥
A minimal priority queuing gateway built with FastAPI using Redis.
It is designed to sit between your clients and a backend REST API, managing two priority levels—high and low—using the [`rq` package](https://python-rq.org/). Requests are enqueued based on the request path and processed synchronously by dedicated worker processes, so the overall throughput is limited by the number of workers.
## Overview
- Intercepts incoming client requests and forwards them to a target REST API.
- Enqueues requests into either a high-priority or low-priority queue based on configurable path matching.
- Processes queued requests via worker processes running in a separate environment.
- Offers Dockerized deployment for both the gateway and worker processes.
## Configuration ⚙️
Both the gateway and workers are fully configurable via the following environment variables.
### Gateway
| ENV | Description | Required | Default |
|-------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------|----------|-----------|
| FAST_PRIORITY_TARGET_BASE_URL | Base url of the target REST api which should run behind the gateway | x | |
| FAST_PRIORITY_HIGH_PRIO_PATHS | Switch between **listed** and **unlisted** modes. If **listed** (**unlisted**) the paths defined in the _PATH_ env variables are put on the **high** (**low**) queue | | unlisted |
| FAST_PRIORITY_PRIO_PATHS | Comma separated list of paths on the target API that should have low priority. Low priority for exact matches | | None |
| FAST_PRIORITY_PRIO_BASE_PATHS | Comma separated list of paths on the target API that should have low priority. Low priority if a request paths starts with the value. | | None |
| FAST_PRIORITY_PASS_THROUGH | Comma separated list of paths on the target API that should skip the queue. Request will be directly be passed on. | | health/ |
| FAST_PRIORITY_POLL_INTERVAL | How often should each request check if the job is finished | | 1.0 |
| FAST_PRIORITY_TTL | Time-to-live (in seconds) for jobs on the queues. | | 300 |
| FAST_PRIORITY_REDIS_HOST | Redis host | | localhost |
| FAST_PRIORITY_REDIS_PORT | Redis port | | 6379 |
| FAST_PRIORITY_REDIS_USER | Redis username | | None |
| FAST_PRIORITY_REDIS_PASSWORD | Redis password | | None |
### Queue worker (docker)
| ENV | Description | Required | Default |
|-------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------|----------|-----------|
| FAST_PRIORITY_WORKERS | Set (e.g., non-empty or a number) to run as a worker instead of the gateway. Controls the number of worker processes to launch. | x | |
| FAST_PRIORITY_REDIS_HOST | Redis host | | localhost |
| FAST_PRIORITY_REDIS_PORT | Redis port | | 6379 |
| FAST_PRIORITY_REDIS_USER | Redis username | | None |
| FAST_PRIORITY_REDIS_PASSWORD | Redis password | | None |
## Usage
Fast Priority Queue is designed to run via Docker (or Docker Compose) or using the script installed with the package `run-fast-priority`. The configuration works the same for both approaches using the environment variables described in [Configuration section](#configuration). The script is mainly provide to give the user the flexibility to include the gateway in their own docker containers by installing the package via pypi.
For development (or more specialized application) the gateway can also be run using the underlying command like this:
```bash
fastapi run fast_priority/app.py --host 0.0.0.0 --port 8001
rq worker high low
```
### Docker 🐳
You can build the Docker container using the provided Dockerfile. The container adapts its run mode based on the presence of the environment variable `FAST_PRIORITY_WORKER`:
- If `FAST_PRIORITY_WORKER` is set, the container starts the worker(s).
- If not, the gateway is started.
The same strategy can be used with you own container and installing the package in the Dockerfile from pypi.
#### Examples
```bash
# API
docker run -p 8010:8000 -e FAST_PRIORITY_TARGET_BASE_URL=http://localhost:8011 -e FAST_PRIORITY_REDIS_HOST=localhost fast_priority:latest
# Workers
docker run -p 8010:8000 -e FAST_PRIORITY_WORKER=1 -e FAST_PRIORITY_REDIS_HOST=localhost fast_priority:latest
```
#### Compose 🐳🐳🐳
The simplest way to run Fast Priority Queue and its dependencies is via Docker Compose. Below is an example configuration:
```yml
services:
behind_gateway_api:
...
priorityity-gateway:
image: fast_priority:latest
environment:
- FAST_PRIORITY_TARGET_BASE_URL=http://behind_gateway_api:8000
- FAST_PRIORITY_REDIS_HOST=queue
- FAST_PRIORITY_PRIO_PATHS=endpoint_1,endpoint_2
ports:
- 8066:8000
priority-gateway-worker:
image: fast_priority:latest
environment:
- FAST_PRIORITY_WORKERS=1
- FAST_PRIORITY_REDIS_HOST=queue
networks:
- default
queue:
image: redis
networks:
- default
networks:
default:
driver: bridge
```
## Contributing
Contributions to Fast Priority Queue are welcome! Feel free to open issues or submit pull requests with improvements, bug fixes, or feature suggestions.
Raw data
{
"_id": null,
"home_page": null,
"name": "fast-priority",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.12",
"maintainer_email": null,
"keywords": "queue, fastapi, priority, redis",
"author": null,
"author_email": "Korbinian Schweiger <korbinian.schweiger@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/b8/cf/05967b6daf8a4e2e500fce4d6072322d69ec4d4d3922d0d50fe41d76dfe4/fast_priority-0.0.14.tar.gz",
"platform": null,
"description": "# \ud83d\ude80 Fast Priority Queue \ud83d\udd25\n\nA minimal priority queuing gateway built with FastAPI using Redis.\n\nIt is designed to sit between your clients and a backend REST API, managing two priority levels\u2014high and low\u2014using the [`rq` package](https://python-rq.org/). Requests are enqueued based on the request path and processed synchronously by dedicated worker processes, so the overall throughput is limited by the number of workers.\n\n## Overview\n\n- Intercepts incoming client requests and forwards them to a target REST API.\n- Enqueues requests into either a high-priority or low-priority queue based on configurable path matching.\n- Processes queued requests via worker processes running in a separate environment.\n- Offers Dockerized deployment for both the gateway and worker processes.\n\n\n## Configuration \u2699\ufe0f\n\nBoth the gateway and workers are fully configurable via the following environment variables.\n\n### Gateway\n\n| ENV | Description | Required | Default |\n|-------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------|----------|-----------|\n| FAST_PRIORITY_TARGET_BASE_URL | Base url of the target REST api which should run behind the gateway | x | |\n| FAST_PRIORITY_HIGH_PRIO_PATHS | Switch between **listed** and **unlisted** modes. If **listed** (**unlisted**) the paths defined in the _PATH_ env variables are put on the **high** (**low**) queue | | unlisted |\n| FAST_PRIORITY_PRIO_PATHS | Comma separated list of paths on the target API that should have low priority. Low priority for exact matches | | None |\n| FAST_PRIORITY_PRIO_BASE_PATHS | Comma separated list of paths on the target API that should have low priority. Low priority if a request paths starts with the value. | | None |\n| FAST_PRIORITY_PASS_THROUGH | Comma separated list of paths on the target API that should skip the queue. Request will be directly be passed on. | | health/ |\n| FAST_PRIORITY_POLL_INTERVAL | How often should each request check if the job is finished | | 1.0 |\n| FAST_PRIORITY_TTL | Time-to-live (in seconds) for jobs on the queues.\t | | 300 |\n| FAST_PRIORITY_REDIS_HOST | Redis host | | localhost |\n| FAST_PRIORITY_REDIS_PORT | Redis port | | 6379 |\n| FAST_PRIORITY_REDIS_USER | Redis username | | None |\n| FAST_PRIORITY_REDIS_PASSWORD | Redis password | | None |\n\n### Queue worker (docker)\n\n| ENV | Description | Required | Default |\n|-------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------|----------|-----------|\n| FAST_PRIORITY_WORKERS | Set (e.g., non-empty or a number) to run as a worker instead of the gateway. Controls the number of worker processes to launch. | x | |\n| FAST_PRIORITY_REDIS_HOST | Redis host | | localhost |\n| FAST_PRIORITY_REDIS_PORT | Redis port | | 6379 |\n| FAST_PRIORITY_REDIS_USER | Redis username | | None |\n| FAST_PRIORITY_REDIS_PASSWORD | Redis password | | None |\n\n## Usage\n\nFast Priority Queue is designed to run via Docker (or Docker Compose) or using the script installed with the package `run-fast-priority`. The configuration works the same for both approaches using the environment variables described in [Configuration section](#configuration). The script is mainly provide to give the user the flexibility to include the gateway in their own docker containers by installing the package via pypi.\n\nFor development (or more specialized application) the gateway can also be run using the underlying command like this:\n\n```bash\nfastapi run fast_priority/app.py --host 0.0.0.0 --port 8001\nrq worker high low\n```\n\n### Docker \ud83d\udc33\n\nYou can build the Docker container using the provided Dockerfile. The container adapts its run mode based on the presence of the environment variable `FAST_PRIORITY_WORKER`:\n\n- If `FAST_PRIORITY_WORKER` is set, the container starts the worker(s).\n- If not, the gateway is started.\n\nThe same strategy can be used with you own container and installing the package in the Dockerfile from pypi.\n\n\n#### Examples\n\n```bash\n# API\ndocker run -p 8010:8000 -e FAST_PRIORITY_TARGET_BASE_URL=http://localhost:8011 -e FAST_PRIORITY_REDIS_HOST=localhost fast_priority:latest\n\n# Workers\ndocker run -p 8010:8000 -e FAST_PRIORITY_WORKER=1 -e FAST_PRIORITY_REDIS_HOST=localhost fast_priority:latest\n```\n\n\n#### Compose \ud83d\udc33\ud83d\udc33\ud83d\udc33\n\nThe simplest way to run Fast Priority Queue and its dependencies is via Docker Compose. Below is an example configuration:\n\n```yml\nservices:\n behind_gateway_api:\n ...\n priorityity-gateway:\n image: fast_priority:latest\n environment:\n - FAST_PRIORITY_TARGET_BASE_URL=http://behind_gateway_api:8000\n - FAST_PRIORITY_REDIS_HOST=queue\n - FAST_PRIORITY_PRIO_PATHS=endpoint_1,endpoint_2\n ports:\n - 8066:8000\n\n priority-gateway-worker:\n image: fast_priority:latest\n environment:\n - FAST_PRIORITY_WORKERS=1\n - FAST_PRIORITY_REDIS_HOST=queue\n networks:\n - default\n queue:\n image: redis\n networks:\n - default\n\nnetworks:\n default:\n driver: bridge\n\n```\n\n\n## Contributing\nContributions to Fast Priority Queue are welcome! Feel free to open issues or submit pull requests with improvements, bug fixes, or feature suggestions.\n\n\n",
"bugtrack_url": null,
"license": null,
"summary": "Simple and streigt forward priority queing gateway using fastapi",
"version": "0.0.14",
"project_urls": null,
"split_keywords": [
"queue",
" fastapi",
" priority",
" redis"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "501dfb11c61a9f86e6edf7cc81d42f1fac60c08d9d55b6a6963e8b41a67d3845",
"md5": "a9919b6a8f11d5e653a7982026096156",
"sha256": "8d199e7f70a0f348a20fe7edbb084cda9d9f9d7c720473fe8ea17bff4af265a9"
},
"downloads": -1,
"filename": "fast_priority-0.0.14-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a9919b6a8f11d5e653a7982026096156",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.12",
"size": 8209,
"upload_time": "2025-02-22T13:22:04",
"upload_time_iso_8601": "2025-02-22T13:22:04.923566Z",
"url": "https://files.pythonhosted.org/packages/50/1d/fb11c61a9f86e6edf7cc81d42f1fac60c08d9d55b6a6963e8b41a67d3845/fast_priority-0.0.14-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "b8cf05967b6daf8a4e2e500fce4d6072322d69ec4d4d3922d0d50fe41d76dfe4",
"md5": "83ce7ebe745ae746cf843c26839e93ab",
"sha256": "c5acf35104e6c7166c4c16de6a66478bf8a4e380c578c94cc28f3d55ce4d7854"
},
"downloads": -1,
"filename": "fast_priority-0.0.14.tar.gz",
"has_sig": false,
"md5_digest": "83ce7ebe745ae746cf843c26839e93ab",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.12",
"size": 7142,
"upload_time": "2025-02-22T13:22:08",
"upload_time_iso_8601": "2025-02-22T13:22:08.445352Z",
"url": "https://files.pythonhosted.org/packages/b8/cf/05967b6daf8a4e2e500fce4d6072322d69ec4d4d3922d0d50fe41d76dfe4/fast_priority-0.0.14.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-02-22 13:22:08",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "fast-priority"
}