# `ZenWebsocket.Config`
[🔗](https://github.com/ZenHive/zen_websocket/blob/v0.4.2/lib/zen_websocket/config.ex#L1)

Configuration struct for WebSocket connections.

## Options

- `:url` - WebSocket URL (required, must be ws:// or wss://)
- `:headers` - HTTP headers for the upgrade request (default: [])
- `:timeout` - Connection timeout in milliseconds (default: 5000)
- `:retry_count` - Maximum reconnection attempts (default: 3)
- `:retry_delay` - Base delay for exponential backoff in ms (default: 1000)
- `:heartbeat_interval` - Interval for heartbeat messages in ms (default: 30000)
- `:max_backoff` - Maximum delay between reconnection attempts in ms (default: 30000)
- `:reconnect_on_error` - Whether to auto-reconnect on connection errors (default: true)
- `:restore_subscriptions` - Whether to restore subscriptions after reconnect (default: true)
- `:request_timeout` - Timeout for correlated requests in ms (default: 30000)
- `:debug` - Enable verbose debug logging (default: false)
- `:latency_buffer_size` - Size of circular buffer for latency stats (default: 100)
- `:record_to` - Path to JSONL file for session recording (default: nil, disabled)

## Examples

    # Basic configuration
    {:ok, config} = Config.new("wss://example.com")

    # Custom reconnection settings
    {:ok, config} = Config.new("wss://example.com",
      retry_count: 5,
      retry_delay: 2000,
      max_backoff: 60_000,
      reconnect_on_error: true
    )

    # Disable auto-reconnection
    {:ok, config} = Config.new("wss://example.com",
      reconnect_on_error: false
    )

## API Functions
| Function | Arity | Description | Param Kinds |
| --- | --- | --- | --- |
| `validate` | 1 | Validate an existing configuration struct. | `config: value` |
| `new!` | 2 | Create and validate a new configuration, raising on error. | `url: value`, `opts: value` |
| `new` | 2 | Create and validate a new WebSocket configuration. | `url: value`, `opts: value` |

# `t`

```elixir
@type t() :: %ZenWebsocket.Config{
  debug: boolean(),
  headers: [{String.t(), String.t()}],
  heartbeat_interval: pos_integer(),
  latency_buffer_size: pos_integer(),
  max_backoff: pos_integer(),
  reconnect_on_error: boolean(),
  record_to: String.t() | nil,
  request_timeout: pos_integer(),
  restore_subscriptions: boolean(),
  retry_count: non_neg_integer(),
  retry_delay: pos_integer(),
  timeout: pos_integer(),
  url: String.t()
}
```

# `new`

```elixir
@spec new(
  String.t(),
  keyword()
) :: {:ok, t()} | {:error, String.t()}
```

Creates and validates a new configuration.

# `new!`

```elixir
@spec new!(
  String.t(),
  keyword()
) :: t()
```

Creates and validates a new configuration, raising on error.

# `validate`

```elixir
@spec validate(t()) :: {:ok, t()} | {:error, String.t()}
```

Validates a configuration struct.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
