brq
Project description
This project is inspired by arq. Not intentionally dividing the community, I desperately needed a redis queue based on redis stream for work reasons and just decided to open source it.
You should also consider arq as more of a library: https://github.com/samuelcolvin/arq/issues/437
brq
Prerequisites
Redis >= 6.2, tested with latest docker image
Install
pip install brq
Feature
See examples for runnable examples.
- Defer job
- Automatic retry job
- Dead queue
- Multiple consumers
Echo jobs overview
Producer
import os
from brq.producer import Producer
from brq.tools import get_redis_client, get_redis_url
async def main():
redis_url = get_redis_url(
host=os.getenv("REDIS_HOST", "localhost"),
port=int(os.getenv("REDIS_PORT", 6379)),
db=int(os.getenv("REDIS_DB", 0)),
cluster=bool(os.getenv("REDIS_CLUSTER", False)),
tls=bool(os.getenv("REDIS_TLS", False)),
)
async with get_redis_client(redis_url) as async_redis_client:
await Producer(async_redis_client).run_job("echo", ["hello"])
if __name__ == "__main__":
import asyncio
asyncio.run(main())
Consumer
import os
from brq.consumer import Consumer
from brq.daemon import Daemon
from brq.tools import get_redis_client, get_redis_url
async def echo(message):
print(message)
async def main():
redis_url = get_redis_url(
host=os.getenv("REDIS_HOST", "localhost"),
port=int(os.getenv("REDIS_PORT", 6379)),
db=int(os.getenv("REDIS_DB", 0)),
cluster=bool(os.getenv("REDIS_CLUSTER", False)),
tls=bool(os.getenv("REDIS_TLS", False)),
)
async with get_redis_client(redis_url) as async_redis_client:
daemon = Daemon(Consumer(async_redis_client, echo))
await daemon.run_forever()
if __name__ == "__main__":
import asyncio
asyncio.run(main())
Develop
Install pre-commit before commit
pip install pre-commit
pre-commit install
Install package locally
pip install -e .[test]
Run unit-test before PR
pytest -v
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
brq-0.1.0.tar.gz
(69.3 kB
view details)
Built Distribution
brq-0.1.0-py3-none-any.whl
(10.1 kB
view details)
File details
Details for the file brq-0.1.0.tar.gz
.
File metadata
- Download URL: brq-0.1.0.tar.gz
- Upload date:
- Size: 69.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 812317b4bc67962516a488af25f0c1ef7830f8352b214eb2ebffa911bf3edc6d |
|
MD5 | 68b70a220166de74d00242c625d6d300 |
|
BLAKE2b-256 | 17d7d930933525537e2fc9ccb7402fff49ae6ceb41f179a7a2d68ff84837d128 |
File details
Details for the file brq-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: brq-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e7a1f66d3d59cf099b95452db7cce095028d0afbdaac65b2db6a35a8125c4aaa |
|
MD5 | 70eb02be9b261901312a2e57f7524aba |
|
BLAKE2b-256 | 2d138a534912565105d1e2fe6be24fa7029f7fd0959a7535a617cebbe904eba4 |