mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-31 19:45:15 +02:00
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:
parent
5d90fbe99f
commit
d6dfe53d62
6 changed files with 369 additions and 0 deletions
20
surfsense_backend/app/event_bus/__init__.py
Normal file
20
surfsense_backend/app/event_bus/__init__.py
Normal 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",
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue