# `TypeDB.HTTP.Finch`
[🔗](https://github.com/NoeticEcho/TypedbEx/blob/v0.11.1/typedb/lib/typedb/http/finch.ex#L1)

Default `TypeDB.HTTP` adapter, backed by [Finch](https://hex.pm/packages/finch).

Each connection starts and supervises its own Finch instance, named after the
connection, so pools are sized per TypeDB server and never shared by accident.
The pool is torn down with the connection.

## Why this is the default

Measured against a local TypeDB 3.12.1 with 400 requests per run:

| Concurrency | `:httpc` | Finch |
| --- | --- | --- |
| 16 | 344 req/s, p50 45ms | 1729 req/s, p50 8ms |
| 64 | 247 req/s, p50 263ms | 1773 req/s, p50 23ms |
| 200 | 77 req/s, p50 2477ms | 1981 req/s, p50 19ms |

`:httpc` does not degrade gracefully: throughput *falls* as concurrency rises.
`TypeDB.HTTP.Httpc` is still supported for environments that must run on OTP
alone, and the numbers above are the price.

## Options

  * `:size` — connections per pool. Defaults to `50`.
  * `:count` — pools per host. Defaults to `1`.
  * `:pools` — a full Finch `:pools` map, which takes precedence over `:size`
    and `:count` when you need per-host tuning.
  * `:conn_opts` — `Mint.HTTP.connect/4` options, merged into the default pool.
    TLS options go here as `transport_opts`.
  * `:pool_timeout` — how long a request waits for a free connection when the
    pool is saturated, in ms. Defaults to Finch's own default of `5_000`.
  * `:name` — an existing Finch instance to use instead of starting one. The
    adapter neither starts nor stops it.

The connection's `:connect_timeout` is applied as `transport_opts[:timeout]` on
the default pool, which is the only place Mint reads a connect timeout from.
Pass your own `conn_opts: [transport_opts: [timeout: …]]` to override it, or a
full `:pools` map to take over pool configuration entirely.

## TLS

Finch verifies certificates by default through `Mint`, which uses the OS trust
store and checks hostnames. To pin a private CA:

    http: {TypeDB.HTTP.Finch, conn_opts: [transport_opts: [cacertfile: "/etc/ssl/private-ca.pem"]]}

# `t`

```elixir
@type t() :: %TypeDB.HTTP.Finch{
  name: atom(),
  owned?: boolean(),
  pool_timeout: timeout() | nil,
  supervisor: pid() | nil
}
```

---

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