WebsockexAdapter.ClientSupervisor (WebsockexAdapter v0.1.1)
View SourceOptional supervisor for WebSocket client connections.
Provides supervised client connections with automatic restart on failure. Each client runs under its own supervisor for isolation.
Adding to Your Supervision Tree
# In your application supervisor
children = [
# Start the ClientSupervisor
WebsockexAdapter.ClientSupervisor,
# Your other children...
]
Supervisor.start_link(children, strategy: :one_for_one)
Usage
# After supervisor is started, create supervised connections
{:ok, client} = ClientSupervisor.start_client("wss://example.com",
retry_count: 5,
heartbeat_config: %{type: :deribit, interval: 30_000}
)
# The client will be automatically restarted on crashes
# with exponential backoff between restarts
Summary
Functions
Returns a specification to start this module under a supervisor.
Lists all supervised client connections.
Starts a supervised WebSocket client.
Starts the client supervisor.
Gracefully stops a supervised client.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
@spec list_clients() :: [pid()]
Lists all supervised client connections.
@spec start_client( String.t() | WebsockexAdapter.Config.t(), keyword() ) :: {:ok, WebsockexAdapter.Client.t()} | {:error, term()}
Starts a supervised WebSocket client.
The client will be automatically restarted on failure according to the supervisor's restart strategy.
Starts the client supervisor.
@spec stop_client(pid()) :: :ok | {:error, :not_found}
Gracefully stops a supervised client.