Reusable Kombu-based publisher/consumer SDK for Django projects.
Project description
wdg-kombu-sdk
A reusable Kombu-based publisher/consumer SDK for Django projects. Easily connect to any message broker (RabbitMQ, Redis, etc.) using Django settings and environment variables.
Features
- Generic broker connection using Kombu
- Publisher and consumer classes for events
- Django settings integration (set broker URL in
.envorsettings.py) - Ready for packaging and PyPI publishing
Installation
pip install wdg-kombu-sdk
Or clone and install locally:
pip install -r requirements.txt
python setup.py install
Configuration
Add your broker URL to your Django .env or settings.py:
BROKER_URL=amqp://guest:guest@localhost:5672//
or in settings.py:
import os
BROKER_URL = os.environ.get('BROKER_URL', 'amqp://guest:guest@localhost:5672//')
Usage
Publisher Example
from wdg_kombu_sdk.publisher import EventPublisher
publisher = EventPublisher() # Uses settings.BROKER_URL by default
publisher.publish_event('user.created', {"id": 1, "name": "Alice"})
Consumer Example
from wdg_kombu_sdk.consumer import EventConsumer
def my_callback(body, message):
print(body)
message.ack()
consumer = EventConsumer('order_saga_compensator', callback=my_callback) # Uses settings.BROKER_URL by default
consumer.start()
Advanced Usage
You can override the broker URL or exchange/queue settings if needed:
publisher = EventPublisher(broker_url='redis://localhost:6379/0', exchange_name='my_events')
consumer = EventConsumer('my_queue', broker_url='redis://localhost:6379/0', exchange_name='my_events')
Publishing to PyPI
- Update
setup.pywith the correct package information. - Build the distribution:
python setup.py sdist bdist_wheel
- Upload to PyPI using
twine:
twine upload dist/*
License
MIT
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wdg-kombu-sdk-0.1.0.tar.gz.
File metadata
- Download URL: wdg-kombu-sdk-0.1.0.tar.gz
- Upload date:
- Size: 8.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cfa5734e7a1d326e9b26395b5b1f54e199661a9403fd6b72b15ee8bb5293f6db
|
|
| MD5 |
711112344fb071077922688195e697e6
|
|
| BLAKE2b-256 |
70310ed54e08e874c0efe892916de235c09ee933cf388ccad0cd5733e01b93fa
|
File details
Details for the file wdg_kombu_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: wdg_kombu_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fbec5f90d29b9b04ae90f94d2b42f5d82e31c1a346ac863b51fa88a979e209b6
|
|
| MD5 |
c7933847d0933cfb2806c111a3613d37
|
|
| BLAKE2b-256 |
da7c6a56cb7da8bf9433bcaf2614e0097843608b637463099914ce65970faa14
|