feat(event_bus): add in-process domain event bus

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.
This commit is contained in:
CREDO23 2026-05-29 15:26:12 +02:00
parent 5d90fbe99f
commit d6dfe53d62
6 changed files with 369 additions and 0 deletions

View file

@ -0,0 +1,20 @@
"""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",
]