brokkr-broker::ws::subscribe
Rust
Read-only WS subscription endpoint for live agent telemetry tail.
Mounted under /api/v1/stacks/{id}/live so it inherits the standard
v1 PAK middleware. The handler then re-applies the same authorisation
the REST history endpoints use (admin OR owning generator) before
upgrading the connection.
Once upgraded, the connection broadcasts every frame the
LiveBroadcaster receives for that stack. When the subscriber lags
past the broadcast capacity, RecvError::Lagged(n) is converted to a
synthetic LogGap message so the UI can render a visible gap
(per ADR-0008’s “a slow subscriber must not slow ingestion”).
Functions
Section titled “Functions”fn subscribe_routes
Section titled “fn subscribe_routes”pub
fn subscribe_routes( dal: DAL, broadcaster: Arc<LiveBroadcaster>,) -> Router<DAL>Build the live-subscription router. Mounted under /api/v1 by the parent so the standard PAK middleware applies; this fn adds its own auth-middleware layer too in case the router is mounted elsewhere.
Source
pub fn subscribe_routes(dal: DAL, broadcaster: Arc<LiveBroadcaster>) -> Router<DAL> { Router::new() .route("/api/v1/stacks/:id/live", get(live_upgrade)) .layer(Extension(broadcaster)) .layer(from_fn_with_state( dal, v1_middleware::auth_middleware::<Body>, )) // Outermost: runs before auth_middleware so it can supply the // Authorization header from the WS subprotocol for browser clients. .layer(from_fn(ws_subprotocol_auth))}Constants
Section titled “Constants”| Name | Type | Value | Description |
|---|---|---|---|
LIVE_SUBSCRIPTION_PATH_TEMPLATE |
&str |
"/api/v1/stacks/:id/live" |
Documented path template (Axum colon-style). The realised path is /api/v1/stacks/{id}/live after the parent router mounts this branch. |