roledesk is built on the boilerplate from here on: pipeline 2.0 (queue and scheduler), auth (one password, sessions, passkeys), the deploy kit and its docs, plus the coupling and packaging tests. Downstream copies, unedited. Refreshed from boilerplate/d56949f7d0f6c0bfe5745478e09007bfad67ae87 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
"""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)]
|