Skip to main content

Asynchronous framework for working with RabbitMQ

Project description

aiocarrot

aiocarrot is a fully asynchronous framework for working with the RabbitMQ message broker


Source Code: https://github.com/d3nbr0/aiocarrot


The key features are:

  • Completely asynchronous - aiocarrot has the aiopika library running under the hood
  • Fast to code - the framework allows you to reduce the amount of code in your project, as well as speed up its development
  • Fields validation - aiocarrot supports field validation using pydantic

Requirements

The following dependencies are required for aiocarrot to work:

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())

You can find more examples here

It's very simple to use. Enjoy!

Project details


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.3.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

aiocarrot-1.0.3-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file aiocarrot-1.0.3.tar.gz.

File metadata

  • Download URL: aiocarrot-1.0.3.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for aiocarrot-1.0.3.tar.gz
Algorithm Hash digest
SHA256 751242a57a515543977ad6fe42e6f146ee7efc1b0a8dbb0ad83063651c29f4b0
MD5 936c2d7cd62a5d3daeb402806d7bffee
BLAKE2b-256 4db1e1179e1b8c5bbb7329376ac78a9bbbf1f8a4b2d9dcd61e36e7c21a88fd0e

See more details on using hashes here.

File details

Details for the file aiocarrot-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: aiocarrot-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for aiocarrot-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0072243a6fd8ffb610b908579b3373f98b4b2febb09ee20e96d73470023d7bf4
MD5 0724b4925590301fdebaec80e3c2392e
BLAKE2b-256 e5b357e83c1d5709284c8a03a24ebd0687975c5df8c59047dda9fd1ffbaa07d4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page