The zimran-events provides amqp interface
Project description
zimran-events
The zimran-py-events
module provides AMQP interface
Installation
pip install zimran-events
Usage example
Producer
from zimran.events import AsyncProducer
producer = AsyncProducer(broker_url='')
await producer.connect()
# message publishing
await producer.publish('some.event.routing', {'msg': 'hello, world'})
Consumer
# < 0.4.0
from zimran.events import Consumer
from zimran.events.dto import Exchange
consumer = Consumer(service_name='my-service', broker_url='')
consumer.add_event_handler(
name='routing-key',
handler=handler_func,
exchange=Exchange(
name='exchange-name',
type='exchange-type',
durable=True,
)
)
# or
from zimran.events import Consumer
consumer = Consumer(service_name='my-service', broker_url='')
@consumer.event_handler('routing-key')
def handler_func(**kwargs):
...
# >= 0.4.0 version
from zimran.events.routing import Router
from zimran.events.consumer AsyncConsumer
router = Router()
@router.event_handler('routing-key')
async def handler(message: aio_pika.IncomingMessage):
pass
router.add_event_handler('routing-key', some_handler)
async def main():
consumer = AsyncConsumer(..., router=router)
await consumer.run()
Code
The code and issue tracker are hosted on GitHub: https://github.com/zimran-tech/zimran-py-events.git
Features
- AMQP interfaces
For contributors
Setting up development environment
Clone the project:
git clone https://github.com/zimran-tech/zimran-py-events.git
cd zimran-py-events
Create a new virtualenv:
python3 -m venv venv
source venv/bin/activate
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
zimran-events-0.4.4.tar.gz
(15.0 kB
view details)
Built Distribution
File details
Details for the file zimran-events-0.4.4.tar.gz
.
File metadata
- Download URL: zimran-events-0.4.4.tar.gz
- Upload date:
- Size: 15.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bdb65a2accdeea023b9b9fac7e69a7f3c2b723e1eef4e73be4b622bdee0691ac |
|
MD5 | b28aa932d423a00ce99cbee9de2f5950 |
|
BLAKE2b-256 | c14c48c9b1d394ad135d86cb4c288c59ac29117c4c09d9ed86fbeb36475bf9ab |
File details
Details for the file zimran_events-0.4.4-py3-none-any.whl
.
File metadata
- Download URL: zimran_events-0.4.4-py3-none-any.whl
- Upload date:
- Size: 11.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9342b96163bfb29f80bed8414e497bfe9fc382fb19e4272f4dc6ea21e11b63b8 |
|
MD5 | e5b024b06b953f2fe03546c3c9b25498 |
|
BLAKE2b-256 | 121685b567d6470093848dc023bcecb46a8087ab3f86456476a1b745e8cee43c |