OffBroadwayWebSocket.State (off_broadway_websocket v0.2.2)

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(),
  headers: list(),
  http_opts: map(),
  last_pong: DateTime.t() | nil,
  max_demand: non_neg_integer(),
  message_queue: :queue.queue(),
  min_demand: non_neg_integer(),
  path: String.t(),
  pid: pid() | nil,
  queue_size: non_neg_integer(),
  stream_ref: reference() | nil,
  telemetry_id: atom(),
  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.
    • :ws_opts - WebSocket options for gun.
    • :http_opts - HTTP options for gun.
    • :ws_timeout - Optional timeout for WebSocket operations.
    • :headers: - Optional headers to use when upgrading to WebSocket.
    • :telemetry_id - Optional ID to be used when emitting telemetry events. Defaults to :websocket_producer

Returns

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