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

`TypeDB.HTTP` adapter built on OTP's `:httpc`, for deployments that must run on
OTP alone.

`TypeDB.HTTP.Finch` is the default and is several times faster under
concurrency — see `TypeDB.HTTP` for the measurements. Choose this one when
reaching outside OTP is not an option, and know what it costs.

Each connection gets its own `:httpc` profile, so connection pooling, keep-alive
and socket limits are isolated from the rest of the application (and from other
`TypeDB` connections).

## Options

  * `:profile` — an existing or new `:httpc` profile to use instead of the
    adapter's own. Naming one makes it **yours**: the adapter starts it if it
    is not running and applies the options below to it, but never stops it.
    Left unset, the adapter starts a profile of its own, named after the
    connection, and stops it with the connection.
  * `:max_sessions` — max simultaneous sockets per host. Defaults to `50`.
  * `:max_keep_alive_length` — how many requests `:httpc` may queue onto a
    socket that is already busy. **Defaults to `0`, and raising it is a
    decision about head-of-line blocking**, not about throughput: anything
    above `0` means a request TypeDB is slow to answer — one waiting on the
    schema lock, a long analytical read — delays every request queued behind
    it on the same socket. At `100`, which this adapter used to default to, a
    500ms wait on one query made a concurrent one wait the same 500ms and
    then some. `0` opens another socket instead, bounded by `:max_sessions`,
    and measured faster at every concurrency above one.
  * `:keep_alive_timeout` — idle keep-alive socket lifetime, ms. Defaults to
    `120_000`.
  * `:ssl` — TLS options passed to `:ssl`. Merged over the secure defaults
    below, so you only need to override what differs.
  * `:cacertfile` — convenience shortcut for a custom CA bundle path.

## TLS

Certificate verification is **on** by default and cannot be disabled by
accident: the defaults are `verify: :verify_peer`, the OS trust store via
`:public_key.cacerts_get/0`, hostname checking via
`:public_key.pkix_verify_hostname_match_fun(:https)`, and TLS 1.2/1.3.

To pin a private CA, in the connection's options:

    http: {TypeDB.HTTP.Httpc, cacertfile: "/etc/ssl/private-ca.pem"}

# `t`

```elixir
@type t() :: %TypeDB.HTTP.Httpc{
  owned?: boolean(),
  profile: atom(),
  ssl_opts: keyword()
}
```

---

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