aio-easy-rabbit
An opinionated way to use RabbitMQ in Asyncio based frameworks.
Installation
to be continued ...
Usage example
Simple consumer example in a FastAPI
from fastapi import FastAPI
from aio_easy_rabbit.connection import (
connect_to_rabbitmq,
start_listening_to_queue,
)
app = FastAPI()
@rabbitmq_consumer("test_queue")
async def test_consumer(message):
print(message)
@app.on_event("startup")
async def startup_event():
registry = ConsumerRegistry()
rabbitmq_connection_string = "amqp://guest:guest@localhost"
app.state.rabbitmq_connection = await connect_to_rabbitmq(
rabbitmq_connection_string
)
for queue_name in registry.get_registered_queues():
asyncio.create_task(
start_listening_to_queue(app.state.rabbitmq_connection, queue_name)
)
Key component is the ConsumerRegistry that will manage state of all registered queues and their consuming functions.
Note: Each decorated consumer will receive a raw string that needs to be serialized as pleased.
Simple publisher example in FastAPI
from fastapi import FastAPI
from aio_easy_rabbit.connection import (
connect_to_rabbitmq
)
from aio_easy_rabbit.producers import RabbitMQPublisher
app = FastAPI()
class Message(BaseModel):
message: str
@app.post("/test/{queue_name}/")
async def test_endpoint(queue_name: str, message: Message):
await app.state.rabbitmq_publisher.publish_message(queue_name, message)
return {"message": "Message published"}
@app.on_event("startup")
async def startup_event():
rabbitmq_connection_string = "amqp://guest:guest@localhost"
app.state.rabbitmq_connection = await connect_to_rabbitmq(
rabbitmq_connection_string
)
app.state.rabbitmq_publisher = RabbitMQPublisher(rabbitmq_connection_string)
Metadata
Release files for aio-easy-rabbit 0.0.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 |
|---|---|---|---|---|
| aio-easy-rabbit-0.0.1.tar.gz | 4.3 kB | Without provenance | Details for aio-easy-rabbit-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| aio_easy_rabbit-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for aio_easy_rabbit-0.0.1-py3-none-any.whl |
Total release size: 10.5 kB
Release files / aio-easy-rabbit-0.0.1.tar.gz
| Download URL | aio-easy-rabbit-0.0.1.tar.gz |
|---|---|
| Size | 4.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b4a1fcaff12690948069dabf5d956ef0401c3225db2605d96c0c3f0464e25fc5
|
|
BLAKE2b-256 checksum How to use checksums |
f9babb8f25e66d2c136644aa91ffd00ba9d6d432284a0246b561860da45aa179
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|
Release files / aio_easy_rabbit-0.0.1-py3-none-any.whl
| Download URL | aio_easy_rabbit-0.0.1-py3-none-any.whl |
|---|---|
| Size | 6.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
080d12e6a9fa9693703d92c8b719576f3d622a5403d54b445da45548492680f5
|
|
BLAKE2b-256 checksum How to use checksums |
19b0b46bf2ef70702cc5a2bce7ae5919af3408633757d733dd7c34867ef44fb0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|
Security for aio-easy-rabbit 0.0.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.