Skip to main content

Module ws

Module ws 

Source
Expand description

WebSocket subscriber for the engine’s /ws push surface.

Subscribes to the engine’s broadcast channel, decodes typed events, and folds them into an EngineState mirror. Handles reconnection with exponential backoff; the TUI status bar reads EngineState::connection to render a DEGRADED banner during partition.

Mirrors ConnectionManager.broadcast() in the engine’s FastAPI server — event shape is {event: string, ts: iso8601, data: object}. Unknown event kinds are preserved in EngineEvent::Unknown so the engine can evolve its push surface without breaking the subscriber.

Structs§

ReconnectConfig
Configuration for the subscriber’s reconnect behavior.
WsSubscriber
Handle to a running WS subscriber task.

Enums§

EngineEvent
Typed event the subscriber emits to consumers. Known events are decoded into strong types; anything else lands in EngineEvent::Unknown with the raw payload.
JitterMode
How to jitter an exponential backoff delay before sleeping.
WsError
Errors the subscriber can surface to its caller. Reconnectable errors are handled internally via backoff and never bubble out; only construction-time and shutdown errors reach the caller.

Functions§

apply_jitter
Apply mode to a computed backoff cap.
exp_backoff_cap
Compute the exponential-backoff cap for a given attempt count (0-based: attempt 0 uses initial, attempt 1 uses initial * multiplier, etc.), clamped to max.