Arend
A simple producer-consumer library for the Beanstalkd queue.
Installation
Hit the command:
pip install arend
Basic Usage
In your code:
from arend import arend_task
from arend.backends.mongo import MongoSettings
from arend.brokers import BeanstalkdSettings
from arend.settings import ArendSettings
from arend.worker import consumer
settings = ArendSettings(
beanstalkd=BeanstalkdSettings(host="beanstalkd", port=11300),
backend=MongoSettings(
mongo_connection="mongodb://user:pass@mongo:27017",
mongo_db="db",
mongo_collection="Tasks"
),
)
@arend_task(queue="my_queue", settings=settings)
def double(num: int):
return 2 * num
double(2) # returns 4
task = double.apply_async(args=(4,)) # It is sent to the queue
consumer(queue="my_queue", settings=settings) # consume tasks from the queue
Task = settings.get_backend() # you can check your backend for the result
task = Task.get(uuid=task.uuid)
assert task.result == 4
Backends
The available backends to store logs are Mongo and Redis. Please read the docs for further information.
Setting your backend with environment variables
You can set your backend by defining env vars.
The AREND__ prefix indicates that it belongs to the Arend.
# Redis
AREND__REDIS_HOST='redis'
AREND__REDIS_DB='1'
AREND__REDIS_PASSWORD='pass'
...
# Mongo
AREND__MONGO_CONNECTION='mongodb://user:pass@mongo:27017'
AREND__MONGO_DB='db'
AREND__MONGO_COLLECTION='logs'
...
In your code:
from arend import arend_task
from arend.worker import consumer
@arend_task(queue="my_queue")
def double(num: int):
return 2 * num
double.apply_async(args=(4,)) # It is sent to the queue
consumer(queue="my_queue")
Documentation
Please visit this link for documentation.
Metadata
Release files for arend 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| arend-0.1.0.tar.gz | 9.5 kB | Without provenance | Details for arend-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| arend-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for arend-0.1.0-py3-none-any.whl |
Total release size: 22.7 kB
Release files / arend-0.1.0.tar.gz
| Download URL | arend-0.1.0.tar.gz |
|---|---|
| Size | 9.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c85bbeee5a2a827069b2744d2deef8fda7909090b29c0c1d23375fdf330010f8
|
|
BLAKE2b-256 checksum How to use checksums |
cbe24945de89a05a86a8719a1e9acd38a0d2b7656f9ac24b745aa6e389ad254c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.10.2 Linux/5.10.104-linuxkit
|
Release files / arend-0.1.0-py3-none-any.whl
| Download URL | arend-0.1.0-py3-none-any.whl |
|---|---|
| Size | 13.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
de80004d6ce5c7a66485971c7af716004fc447ef1e365caa1268b0e9bb2af546
|
|
BLAKE2b-256 checksum How to use checksums |
877f80e4c197a7e2cf76af6ec202d7e3e5e2e27163989872ff242fe0354bd173
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.10.2 Linux/5.10.104-linuxkit
|
Security for arend 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.