feat(pubsub): get_event_bus() late-import accessor

This commit is contained in:
Tyler
2026-06-20 15:35:02 -06:00
parent b2f5a16541
commit 25a76a515d
2 changed files with 23 additions and 1 deletions
+12
View File
@@ -56,3 +56,15 @@ class EventBus:
while True:
yield await queue.get()
queue.task_done()
def get_event_bus() -> EventBus:
"""Return the process-wide EventBus attached to the FastAPI app state.
Late-imports ``cyclone.api`` to avoid a circular import at module
load time (the API module imports pubsub indirectly via lifespan).
Tests stub this via monkeypatch.
"""
from cyclone.api import app # late import to avoid circular
return app.state.event_bus