Brokkoly
Brokkoly is a framework for enqueuing messages via HTTP request for celery.
Example
tasks.py:
import brokkoly
b = brokkoly.Brokkoly('example', 'redis://localhost:6379/0')
celery = b.celery
def two_times(text: str) -> dict:
return {
'text': text * 2
}
@b.task(two_times)
def echo(text: str) -> None:
print(text)
two_times works as pre processor. It works before enqueing. It means it can return BadRequest to your client. Brokkoly validate message with typehint. Also you can have extra validation and any other process here.
Run celery -A tasks worker --loglevel=info
producer.py:
import brokkoly
import tasks # NOQA
application = brokkoly.producer()
producer is WSGI application. You need to import your tasks for put message into queue.
Run with uWSGI uwsgi --http :8080 --wsgi-file producer.py --enable-threads --thunder-lock --master
Send Test Message!
curl -X POST -d '{"message":{"text": "Hello"}}' http://localhost:8080/example/echo
producer receives your request
producer validates your message having text and the type is str or not. text`(str) is from typehint of
two_timesproducer validates two_times returned value having text and the type is str or not. text`(str) is from typehint of
echoproducer put message
{"message":{"text":"HelloHello"}}into queue.curl receives response.
Celery calls
echo
Extra
preprocessor is optional. if you don’t need it, you can:
@b.task()
def echo(text: str) -> None:
print(text)
Also you can give multiple preprocessor:
@b.task(two_times, two_times)
def echo(text: str) -> None:
print(text)
Metadata
Release files for brokkoly 0.3.1
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 |
|---|---|---|---|---|
| brokkoly-0.3.1.tar.gz | 11.7 kB | Without provenance | Details for brokkoly-0.3.1.tar.gz |
Release files / brokkoly-0.3.1.tar.gz
| Download URL | brokkoly-0.3.1.tar.gz |
|---|---|
| Size | 11.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
db45bcdc3c9db4b777fd462e792569c2a363af410dc6b5bdd33c6fa9efa5aeac
|
|
BLAKE2b-256 checksum How to use checksums |
de585d047be1bceaa48bd37dd5c809294254adea0a873f00a66461c53bf8724f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for brokkoly 0.3.1
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.