"""How a route reaches the queue and the socket bus. Both are built once by the app's factory and parked on `app.state`. Routes ask for them as dependencies rather than closing over them, so a router module is importable on its own and a test can replace either through `app.dependency_overrides`. Only the two things that are the *pipeline's*. An app's own store and config are its own business and stay in its own `deps` — the queue and the bus are here because `pipeline.web.jobs` is here, and it needs them whichever app it is mounted in. """ from __future__ import annotations from typing import Annotated from fastapi import Depends from starlette.requests import HTTPConnection from pipeline import JobQueue from pipeline.web.broadcaster import Broadcaster def get_queue(request: HTTPConnection) -> JobQueue: return request.app.state.queue def get_broadcaster(request: HTTPConnection) -> Broadcaster: return request.app.state.bus QueueDep = Annotated[JobQueue, Depends(get_queue)] BroadcasterDep = Annotated[Broadcaster, Depends(get_broadcaster)]