Signals API

This module contains the signal handlers used by Django Dispatch.

Signal Handlers

django_broadcaster.signals.handle_outbox_event_signals(sender, instance, created, **kwargs)[source]

Handle signals for outbox events

Django Signals

Django Dispatch uses the following signals from the django_broadcaster.registry module:

  • event_created: Dispatched when an event is created

  • event_published: Dispatched when an event is published

See Registry API for more information on these signals.

Example Usage

from django.dispatch import receiver
from django_broadcaster.registry import event_created, event_published

@receiver(event_created)
def handle_event_created(sender, event, **kwargs):
    """Handle event created signal"""
    print(f"Event created: {event.event_type}")

@receiver(event_published)
def handle_event_published(sender, event, **kwargs):
    """Handle event published signal"""
    print(f"Event published: {event.event_type}")

Internal Signal Flow

  1. When an OutboxEvent is created, the post_save signal is triggered

  2. The handle_outbox_event_signals function receives this signal

  3. If the event is new (created=True), it dispatches the event_created signal

  4. If the event’s status is PUBLISHED, it dispatches the event_published signal

This signal flow allows for decoupled components to react to events being created or published.