feat(pubsub): get_event_bus() late-import accessor
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user