# `Dllb.Pool`
[🔗](https://github.com/Oeditus/dllb_ex/blob/v0.9.0/lib/dllb/pool.ex#L1)

NimblePool-based connection pool for dllb TCP connections.

Workers are raw `:gen_tcp` sockets managed through `Dllb.Connection`.
Dead sockets are detected at checkout and transparently reconnected.

# `batch`

```elixir
@spec batch([String.t()], Keyword.t()) :: [ok: Dllb.Result.t(), error: term()]
```

Executes multiple queries through a single pool checkout.

Checks out one socket, sends all queries sequentially, then checks
the socket back in. This amortises the pool checkout cost across
many queries (e.g. bulk AST ingestion).

Returns a list of `{:ok, result} | {:error, reason}` in the same
order as the input query strings.

# `batch_transaction`

```elixir
@spec batch_transaction([String.t()], Keyword.t()) ::
  {:ok, Dllb.Result.t()} | {:error, term()}
```

Executes multiple queries inside a `BEGIN BATCH ... END BATCH` block
through a single pool checkout.

All statements run in one server-side storage transaction. Returns a
single `{:ok, result}` or `{:error, reason}`.

# `child_spec`

```elixir
@spec child_spec(Keyword.t()) :: Supervisor.child_spec()
```

Returns a child spec for starting the pool under a supervisor.

## Options

  * `:host` - server hostname (default from app env or `"127.0.0.1"`)
  * `:port` - server port (default from app env or `3009`)
  * `:pool_size` - number of connections (default from app env or `30`)
  * `:outcome` - response format (default `:json`)
  * `:timeout` - connection/recv timeout in ms (default `30_000`)

# `query`

```elixir
@spec query(String.t(), Keyword.t()) :: {:ok, Dllb.Result.t()} | {:error, term()}
```

Executes a query through the connection pool.

Checks out a socket, runs the query via `Dllb.Connection.query/3`,
and checks the socket back in.

## Options

  * `:timeout` - recv timeout in ms (default `30_000`)

Returns `{:ok, result}` or `{:error, reason}`.

---

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