WebsockexAdapter.Examples.Docs.ErrorHandling (WebsockexAdapter v0.1.1)
View SourceError handling and retry patterns from Examples.md
Summary
Functions
Returns a specification to start this module under a supervisor.
Returns the current state of the error handler.
Sends a message through the WebSocket connection.
Starts a GenServer that manages a WebSocket connection with automatic retry.
Types
@type state() :: %{ client: pid() | nil, url: String.t(), opts: keyword(), retry_count: non_neg_integer() }
Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
@spec get_state() :: state()
Returns the current state of the error handler.
Returns
The internal state map including connection status and retry count.
@spec send_message(term()) :: :ok | {:error, :not_connected}
Sends a message through the WebSocket connection.
Parameters
message
- Message to send (will be JSON encoded)
Returns
:ok
on success{:error, :not_connected}
if not connected
@spec start_link( String.t(), keyword() ) :: GenServer.on_start()
Starts a GenServer that manages a WebSocket connection with automatic retry.
Parameters
url
- WebSocket URL to connect toopts
- Connection options
Returns
{:ok, pid}
on success or {:error, reason}
on failure.