TypeDB.HTTP.Finch (TypeDB v0.2.0)

Copy Markdown View Source

Default TypeDB.HTTP adapter, backed by 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:httpcFinch
16344 req/s, p50 45ms1729 req/s, p50 8ms
64247 req/s, p50 263ms1773 req/s, p50 23ms
20077 req/s, p50 2477ms1981 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_optsMint.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"]]}

Summary

Types

t()

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