mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-31 19:45:15 +02:00
A standalone, domain-agnostic pub/sub seam: an EventBus that owns its subscriber registry and streams Event values from producers to listeners in process. Boundary-crossing (Celery/DB/workers) is left to subscribers, keeping the bus single-responsibility. Includes the immutable Event value object and full unit coverage.
20 lines
479 B
Python
20 lines
479 B
Python
"""In-process domain event bus.
|
|
|
|
Domain-agnostic pub/sub. Producers ``await bus.publish(...)``; subscribers
|
|
``bus.subscribe(...)``. Domain modules depend on it, never the reverse.
|
|
|
|
from app.event_bus import bus
|
|
await bus.publish("document.indexed", {"document_id": 42}, search_space_id=7)
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from .bus import EventBus, Subscriber, bus
|
|
from .event import Event
|
|
|
|
__all__ = [
|
|
"Event",
|
|
"EventBus",
|
|
"Subscriber",
|
|
"bus",
|
|
]
|