Skip to main content

A Django app implementing the transactional outbox pattern with CloudEvents support

Project description

Django Broadcaster

PyPI version Python versions Django versions License CI Coverage

A Django app that implements the transactional outbox pattern with CloudEvents support, enabling reliable event publishing in distributed systems.

Features

  • 🔄 Transactional Broadcaster Pattern: Ensures events are published reliably
  • ☁️ CloudEvents Compatible: Follows CloudEvents specification
  • 🔌 Multiple Backends: Redis Streams, Kafka, NATS support
  • 🔁 Retry Logic: Exponential backoff with configurable retries
  • 🔑 Idempotency: Prevents duplicate event processing
  • 📊 Monitoring: Built-in metrics and health checks
  • 🎯 Event Handlers: Local event processing framework
  • 🔧 Admin Interface: Django admin integration

Quick Start

Installation

# Using pip
pip install django-broadcaster

# Using uv
uv add django-broadcaster

Configuration

Add to your Django settings:

INSTALLED_APPS = [
    # ... your other apps
    'django_broadcaster',
]

OUTBOX_PUBLISHERS = {
    'default': {
        'BACKEND': 'django_broadcaster.backends.RedisStreamBackend',
        'OPTIONS': {
            'host': 'localhost',
            'port': 6379,
            'stream_name': 'events',
        }
    }
}

Usage

from django_broadcaster.publishers import publisher

# Publish an event
event = publisher.publish_event(
    event_type='user.created',
    source='user-service',
    data={'user_id': 123, 'email': 'user@example.com'}
)

# Register event handler
from django_broadcaster.registry import event_registry

@event_registry.register('user.created')
def handle_user_created(event):
    print(f"User created: {event.data}")

Running the Worker

python manage.py outbox_worker

Documentation

Full documentation is available at https://django-broadcaster.readthedocs.io/en/latest/.

Building and Serving Documentation Locally

To build the documentation locally:

# Build the documentation
make docs-build

# Serve the documentation locally at http://localhost:8080
make docs-serve

After running make docs-serve, you can access the documentation by opening http://localhost:8080 in your web browser.

Contributing

Contributions are welcome! Please read our Contributing Guide for details.

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

django_broadcaster-0.1.0.tar.gz (36.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_broadcaster-0.1.0-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

Details for the file django_broadcaster-0.1.0.tar.gz.

File metadata

  • Download URL: django_broadcaster-0.1.0.tar.gz
  • Upload date:
  • Size: 36.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.12

File hashes

Hashes for django_broadcaster-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a6cd29b50d8f3a67580bfd6c313599869c99a5fc8060532ea3ee529c76d451b2
MD5 097f885ebb6ebcc944b05f737dc8d3de
BLAKE2b-256 a6e7fa7aa267ae93e5ebfdad9e4a16d04fee90c90009b77a79f85ba147d0b89f

See more details on using hashes here.

File details

Details for the file django_broadcaster-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_broadcaster-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5a09ce3b2ba56af12e9a787bb7f664e7ac91b8be31fca1b22fdfcfd74346b407
MD5 51c9e3113d2d75e19f215b41b6a65539
BLAKE2b-256 3e3a820680e01cb12f63dbd030b851bd2bc1aa1eca88a4e9398cfe101eb4ad88

See more details on using hashes here.

Supported by

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