Layer-3 WebSocket adapter GenServer.
Manages connection lifecycle, auth state machine, subscription restoration, spec-driven message routing, semantics state, and Registry broadcast.
Summary
Functions
Returns current auth state.
Runs the auth state machine when credentials are configured.
Returns a specification to start this module under a supervisor.
Returns connection state from the underlying WS client.
Starts a managed WS adapter for the given exchange section.
Subscribes to channels and tracks them for restoration.
Types
@type auth_state() :: :unauthenticated | :authenticating | :authenticated | :expired
@type section() :: Bourse.WS.section()
@type t() :: %Bourse.WS.Adapter{ auth_context: map() | nil, auth_state: auth_state(), auth_timer_ref: reference() | nil, connect_fun: (Bourse.Exchange.t(), section(), keyword() -> {:ok, Bourse.WS.t()} | {:error, term()}), exchange: Bourse.Exchange.t(), ohlcv: Bourse.WS.Semantics.Ohlcv.t(), orderbook: Bourse.WS.Semantics.Orderbook.t(), section: section(), subscriptions: [String.t() | map()], trades: Bourse.WS.Semantics.Trades.t(), ws: Bourse.WS.t() | nil }
Functions
@spec auth_state(GenServer.server()) :: auth_state()
Returns current auth state.
@spec authenticate(GenServer.server()) :: :ok | {:error, term()}
Runs the auth state machine when credentials are configured.
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec connection_state(GenServer.server()) :: :connecting | :connected | :disconnected
Returns connection state from the underlying WS client.
@spec start_link(Bourse.Exchange.t(), section(), keyword()) :: GenServer.on_start()
Starts a managed WS adapter for the given exchange section.
@spec subscribe(GenServer.server(), [String.t() | map()], keyword() | map()) :: :ok | {:ok, map()} | {:error, term()}
Subscribes to channels and tracks them for restoration.