OffBroadwayWebSocket.State (off_broadway_websocket v1.0.2)
Holds the connection and retry state for a WebSocket producer in an Off-Broadway pipeline.
Fields
- url, path – Target WebSocket endpoint.
- gun_opts – Options passed directly to Gun for HTTP/WebSocket setup.
- ws_timeout – Idle timeout for WebSocket frames.
- await_timeout – Timeout for synchronous Gun calls.
- headers – HTTP headers for the upgrade.
- min_demand, max_demand – Broadway demand settings.
- telemetry_id – ID used when firing telemetry events.
- message_queue – Internal buffer for frames before dispatch.
- ws_init_retry_opts, ws_retry_opts – Retry parameters for reconnect logic.
- ws_retry_fun – Function computing delays and next-state.
- pid, conn_pid, stream_ref – Process and stream tracking.
- last_msg_dt, queue_size, total_demand – Monitoring and backpressure.
Summary
Functions
Default function to compute the next reconnect delay and state.
The default retry options map used for WebSocket reconnects.
Builds a new state struct from the given options.
Types
@type retry_opts() :: %{ retries_left: non_neg_integer(), max_retries: non_neg_integer(), delay: non_neg_integer() }
@type t() :: %OffBroadwayWebSocket.State{ await_timeout: non_neg_integer(), conn_pid: pid() | nil, gun_opts: map(), headers: [{String.t(), String.t()}], last_msg_dt: DateTime.t() | nil, max_demand: non_neg_integer(), message_queue: :queue.queue(any()), min_demand: non_neg_integer(), path: String.t() | nil, pid: pid() | nil, queue_size: non_neg_integer(), stream_ref: reference() | nil, telemetry_id: atom(), total_demand: non_neg_integer(), url: String.t() | nil, ws_init_retry_opts: retry_opts() | nil, ws_retry_fun: (retry_opts() -> retry_opts()), ws_retry_opts: retry_opts() | nil, ws_timeout: non_neg_integer() | nil }
Functions
@spec default_ws_retry_fun(retry_opts()) :: retry_opts()
Default function to compute the next reconnect delay and state.
@spec default_ws_retry_opts() :: retry_opts()
The default retry options map used for WebSocket reconnects.
Builds a new state struct from the given options.
Required options:
- :url – WebSocket endpoint
- :path – WebSocket path
Optional:
- :gun_opts, defaults to
%{}
- :ws_timeout, defaults to
nil
- :await_timeout, defaults to 10000
- :headers, defaults to
[]
- :telemetry_id, defaults to :websocket_producer
- :broadway, to customize min_demand/max_demand
- :ws_retry_opts, defaults to default_ws_retry_opts/0