OffBroadwayWebSocket.State (off_broadway_websocket v0.0.4)

Manages the state for WebSocket producer in an Off-Broadway setup. This includes demand tracking, reconnection parameters, and message queuing.

Summary

Functions

Creates a new %State{} struct with specified options.

Types

t()

@type t() :: %OffBroadwayWebSocket.State{
  await_timeout: non_neg_integer(),
  conn_pid: pid() | nil,
  connect_timeout: non_neg_integer(),
  http_opts: map(),
  last_pong: DateTime.t() | nil,
  max_demand: non_neg_integer(),
  message_queue: OffBroadwayWebSocket.Types.queue(),
  min_demand: non_neg_integer(),
  path: String.t(),
  queue_size: non_neg_integer(),
  stream_ref: reference() | nil,
  total_demand: non_neg_integer(),
  url: String.t(),
  ws_opts: map(),
  ws_timeout: non_neg_integer()
}

Functions

new(opts)

@spec new(keyword()) :: t()

Creates a new %State{} struct with specified options.

Parameters

  • opts: A keyword list of options, including:
    • :broadway - Broadway-related options, specifically demand settings.
    • :url - The WebSocket URL.
    • :path - The WebSocket path.
    • :reconnect_delay - Optional delay in milliseconds for reconnection.
    • :ws_opts - WebSocket options for gun.
    • :http_opts - HTTP options for gun.
    • :ws_timeout - Optional timeout for WebSocket operations.

Returns

  • A %State{} struct initialized with the provided options and default values.