Wrapper to pika for an easy to use RabbitMQ interface.
Project description
Snacks
Snacks is a wrapper around pika to provide a convenient interface to publish/subscribe to queues in RabbitMQ.
Example
from snacks.rabbit import RabbitApp
# Setup
rabbit = RabbitApp()
queue = 'snacks'
key = 'snackey'
rabbit.exchange_declare(exchange_type='topic', durable=True)
rabbit.queue_declare(queue=queue, durable=True)
rabbit.queue_bind(queue=queue, routing_key=key)
@rabbit.listener([queue])
def listen(event: str) -> str:
print(f'Received request: {event}')
return 'Rabbits and pikas are snacks.'
if __name__ == '__main__':
r = rabbit.publish_and_receive('To a python.', key, serialize=bytes.decode)
print(f'Received response: {r}')
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
snacks-0.2.1.tar.gz
(6.1 kB
view details)
File details
Details for the file snacks-0.2.1.tar.gz
.
File metadata
- Download URL: snacks-0.2.1.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.4.2 requests/2.24.0 setuptools/51.0.0 requests-toolbelt/0.8.0 tqdm/4.48.2 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d9fc9e30da31d6bb74f02c9fc7ad04bf5587d947a3bd2c0a7bce74df7770a928 |
|
MD5 | 9ea6dc44d758209c42e63855dd416246 |
|
BLAKE2b-256 | 62f89ff0906c47ac6713cf6473e6ef1612c620b400bd06822929cee24a09aa94 |