Quiver.Config (quiver v0.2.0)

Copy Markdown View Source

Consolidated validation for all Quiver configuration.

Summary

Functions

Parses a pool configuration map into a specificity-sorted list of validated rules.

Finds the first matching rule's config for the given origin, or nil.

Validates pool and transport options against the unified schema, applying defaults.

Types

pool_opts()

@type pool_opts() :: [
  size: integer(),
  checkout_timeout: integer(),
  idle_timeout: integer(),
  ping_interval: integer(),
  protocol: :auto | :http1 | :http2,
  max_connections: integer(),
  connect_timeout: integer(),
  recv_timeout: integer(),
  buffer_size: integer(),
  verify: :verify_peer | :verify_none,
  cacerts: :default | [any()],
  alpn_advertised_protocols: [binary()],
  proxy: [
    host: binary(),
    port: integer(),
    scheme: :http | :https,
    headers: any()
  ]
]

Functions

parse_rules(pools_map)

@spec parse_rules(map()) ::
  {:ok, [Quiver.Config.Rule.t()]}
  | {:error,
     Quiver.Error.InvalidPoolRule.t() | Quiver.Error.InvalidPoolOpts.t()}

Parses a pool configuration map into a specificity-sorted list of validated rules.

resolve_config(rules, arg)

@spec resolve_config(
  [Quiver.Config.Rule.t()],
  {atom(), String.t(), :inet.port_number()}
) ::
  keyword() | nil

Finds the first matching rule's config for the given origin, or nil.

validate_pool(opts)

@spec validate_pool(pool_opts()) ::
  {:ok, pool_opts()} | {:error, Quiver.Error.InvalidPoolOpts.t()}

Validates pool and transport options against the unified schema, applying defaults.

  • :size (integer/0) - Number of connections in the pool. The default value is 10.

  • :checkout_timeout (integer/0) - Max wait time in ms to acquire a connection. The default value is 5000.

  • :idle_timeout (integer/0) - Time in ms before idle connections are closed. The default value is 30000.

  • :ping_interval (integer/0) - Interval in ms to check connection health. The default value is 5000.

  • :protocol (:auto | :http1 | :http2) - HTTP protocol version. :auto detects via ALPN negotiation. The default value is :auto.

  • :max_connections (integer/0) - Max HTTP/2 connections per origin. The default value is 1.

  • :connect_timeout (integer/0) - TCP/TLS connect timeout in ms. The default value is 5000.

  • :recv_timeout (integer/0) - Socket receive timeout in ms. The default value is 15000.

  • :buffer_size (integer/0) - Socket receive buffer size in bytes. The default value is 8192.

  • :verify (:verify_peer | :verify_none) - TLS certificate verification mode. The default value is :verify_peer.

  • :cacerts (:default | list of term/0) - CA certificates. :default uses OS store. The default value is :default.

  • :alpn_advertised_protocols (list of String.t/0) - ALPN protocols to advertise during TLS. The default value is [].

  • :proxy (keyword/0)