Skip to main content

Module ws

Module ws 

Source
Expand description

WebSocket handler and watch subscription manager.

This module provides two major components:

  1. WatchManager — a thread-safe subscription registry that manages watch lifecycles (subscribe, poll, unsubscribe, add/remove IDs). Each watch tracks a set of entity IDs and the graph version at last poll, enabling efficient change detection.

  2. ws_handler — an Actix-Web WebSocket upgrade endpoint (GET /api/ws) that handles Haystack watch operations over JSON messages. Supports server-initiated ping/pong liveness, deflate compression for large payloads, and automatic server-push of graph changes to watching clients.

Structs§

WatchManager
Manages watch subscriptions for change polling.

Functions§

ws_handler
WebSocket upgrade handler for /api/ws.