Skip to main content

Module connector

Module connector 

Source
Expand description

Long-lived WebSocket connector + REST-side handle.

The connector is an actor that owns a single bezant::WsClient and drives it forever:

  1. Connect (with exponential-backoff retry).
  2. Subscribe to orders + pnl (always, on every connect).
  3. Loop: dispatch frames into per-topic rings, accept subscribe/unsubscribe commands for market data, watch a heartbeat timeout to detect a stalled socket.
  4. On any disconnect: bump reset_epoch, push a synthetic gap event into every active ring, sleep with backoff, GOTO 1.

EventsHandle is what axum handlers get. Cloneable, cheap, exposes reads against the rings and a command channel into the actor task.

Structs§

ConnectorCfg
Configurable knobs for the connector.
EventsHandle
Cloneable handle the axum handlers use. Reads come straight off the shared ring map; writes go through the command channel.

Functions§

spawn_connector
Spawn the connector task and return a EventsHandle for the axum side. The task owns the bezant::Client reference (cheap, it’s already Arc-wrapped internally) and runs until the binary exits.