# `ZenWebsocket.Examples.BatchSubscriptionManager`
[🔗](https://github.com/ZenHive/zen_websocket/blob/v0.4.2/lib/zen_websocket/examples/batch_subscription_manager.ex#L1)

Simple batch subscription manager for efficiently subscribing to multiple channels.

Prevents overwhelming the API by batching subscription requests with configurable
batch size and delay between batches.

# `batch_status`

```elixir
@type batch_status() :: %{
  completed: non_neg_integer(),
  pending: non_neg_integer(),
  total: non_neg_integer(),
  failed: boolean(),
  error: term() | nil
}
```

# `cancel_batch`

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

Cancels a batch subscription request.

## Parameters
- `manager` - The batch manager process
- `request_id` - The request ID to cancel

## Returns
- `:ok` if cancelled successfully
- `{:error, :not_found}` if request_id is invalid

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `get_all_statuses`

```elixir
@spec get_all_statuses(pid()) :: {:ok, map()}
```

Gets the status of all batch requests.

## Returns
`{:ok, statuses}` where statuses is a map of request_id => status.

# `get_status`

```elixir
@spec get_status(pid(), String.t()) :: {:ok, batch_status()} | {:error, :not_found}
```

Gets the status of a batch subscription request.

## Parameters
- `manager` - The batch manager process
- `request_id` - The request ID returned by subscribe_batch/2

## Returns
- `{:ok, status}` with completed/pending/total counts
- `{:error, :not_found}` if request_id is invalid

# `start_link`

```elixir
@spec start_link(keyword()) :: GenServer.on_start()
```

Starts the batch subscription manager.

## Options
- `:adapter` - The Deribit adapter process (required)
- `:batch_size` - Number of channels per batch (default: 10)
- `:batch_delay` - Delay between batches in ms (default: 200)

## Returns
`{:ok, pid}` on success.

# `subscribe_batch`

```elixir
@spec subscribe_batch(pid(), [String.t()]) :: {:ok, String.t()} | {:error, term()}
```

Subscribes to multiple channels in batches.

## Parameters
- `manager` - The batch manager process
- `channels` - List of channel names to subscribe to

## Returns
`{:ok, request_id}` where request_id can be used to track progress.

---

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