Pixir.Provider.WebSocketClient (pixir v0.1.0)

Copy Markdown View Source

Minimal Responses WebSocket client used by the production Provider connection.

The client intentionally emits the same SSE-shaped chunks that Pixir.Provider already knows how to fold. This keeps the model-event parser in one place while the connection process owns socket lifetime and continuation state.

Summary

Types

handshake()

@type handshake() :: %{status: integer() | nil, status_line: String.t()}

socket()

@type socket() :: term()

Functions

close(socket)

@spec close(socket() | nil) :: {:ok, :noop | :closed} | {:error, term()}

connect(endpoint, headers, opts \\ [])

@spec connect(String.t(), [{String.t(), String.t()}], keyword()) ::
  {:ok, socket(), binary(), handshake()} | {:error, map()}

ping(socket)

@spec ping(socket()) :: :ok | {:error, term()}

stream(socket, initial_buffer, payload, acc, fun, opts \\ [])

@spec stream(socket(), binary(), map(), acc, (term(), acc -> acc), keyword()) ::
  {:ok, acc, map()} | {:error, map(), acc}
when acc: term()