Asynchronous framework for working with RabbitMQ
Project description
aiocarrot
aiocarrot is fully asynchronous framework for working with RabbitMQ
Accelerate development with a message broker at times with aiocarrot
Installation
Create and activate virtual environment and then install aiocarrot:
pip install aiocarrot
Example
Create a file main.py
with:
from aiocarrot import Carrot, Consumer
import asyncio
consumer = Consumer()
@consumer.message(name='multiply')
async def multiply(first_number: int, second_number: int) -> None:
print('Result is:', first_number * second_number)
async def main() -> None:
carrot = Carrot(url='amqp://guest:guest@127.0.0.1/', queue_name='sample')
carrot.setup_consumer(consumer)
await carrot.run()
if __name__ == '__main__':
asyncio.run(main())
Then run it with:
python main.py
Now you have created a consumer with the ability to receive a "multiply" task
Produce message
If you want to send a message, use this:
from aiocarrot import Carrot
import asyncio
async def main() -> None:
carrot = Carrot(url='amqp://guest:guest@127.0.0.1:5672/', queue_name='sample')
await carrot.send('multiply', first_number=10, second_number=20)
if __name__ == '__main__':
asyncio.run(main())
It's very simple to use. Enjoy!
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
aiocarrot-1.0.0.tar.gz
(5.5 kB
view hashes)
Built Distribution
Close
Hashes for aiocarrot-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 161d1dc66a1facc9c541701f92e15163dfb8e9df80af4dcbf7d2d5a05723895a |
|
MD5 | 48e538cb71c7d50b0a54824708a5678a |
|
BLAKE2b-256 | 64d3a79a033d77e2e79d3b845430b10bc49bd0e752dbb3020c81e34bf5ac6cd9 |