pub async fn ws_handler(
req: HttpRequest,
stream: Payload,
state: Data<AppState>,
) -> Result<HttpResponse>Expand description
WebSocket upgrade handler for /api/ws.
Upgrades the HTTP connection to a WebSocket and handles Haystack
watch operations (watchSub, watchPoll, watchUnsub) over JSON
messages. Each client request may include a reqId field which
is echoed back in the response for correlation.
Features:
- Server-initiated ping every [
PING_INTERVAL] for liveness detection - Backpressure: slow clients are disconnected after [
MAX_SEND_FAILURES] - Deflate compression for large responses (binary frames)
- Server-push: graph changes are pushed to watching clients automatically