INNER CODE UNIT · Python
EventBroadcaster
permitio/fastapi_websocket_pubsub · fastapi_websocket_pubsub/event_broadcaster.py:111
class EventBroadcaster:
"""
Bridge EventNotifier to work across processes and machines by sharing their events through a broadcasting channel
Usage:
uri = "postgres://localhost:5432/db_name" #postgres example (also supports REDIS, Kafka, ...)
# start litsening for broadcast publications notifying the internal event-notifier, and subscribing to the internal notifier, broadcasting its notes
broadcaster = EventBroadcaster(uri, notifier):
async with broadcaster.get_context():
<Your Code>
"""
def __init__(
self,
broadcast_url: str,
notifier: EventNotifier,
channel="EventNotifier",
broadcast_type=None,