Quiver.Pool.HTTP3 (quiver v0.3.0)

Copy Markdown View Source

HTTP/3 pool coordinator.

A gen_state_machine per origin that routes concurrent callers to available stream slots across one or more Pool.HTTP3.Connection workers. Mirrors Pool.HTTP2: eagerly opens new connections until max_connections is reached, least-loaded picks across connections with available stream capacity, and queues callers when all slots are saturated.

States: :idle -> :connected. The coordinator self-registers in :persistent_term so that Pool.Manager can detect the protocol from a bare pid. Uses the two-phase caller model: the caller issues a gen_statem call to the coordinator, the coordinator forwards {:forward_request, from, ...} to the connection worker, and the worker replies directly to the caller's from.

HTTP/3 handshake is asynchronous (:connecting -> :connected inside the worker), so a freshly started connection cannot accept requests yet. The worker notifies the coordinator with {:connection_ready, pid, max_streams} on entering :connected, at which point the coordinator flips the per- connection entry from :connecting to :connected and starts picking it.

Summary

Types

t()

@type t() :: %Quiver.Pool.HTTP3{
  checkout_timeout: pos_integer(),
  config: keyword(),
  connections: map(),
  max_connections: pos_integer(),
  origin: term(),
  waiting: :queue.queue()
}

Functions

connected(arg1, arg2, data)

idle(arg1, arg2, data)

open_channel(pool, method, path, headers, channel_opts, opts \\ [])

@spec open_channel(pid(), atom(), String.t(), list(), keyword(), keyword()) ::
  {:ok, Quiver.HTTP3.Channel.t(), reference()} | {:error, term()}

Opens a datagram channel through this pool. Internal entry point used by Quiver.HTTP3.open_datagram_channel/4.

Forwards {:forward_open_channel, from, method, path, headers, channel_opts} to a picked worker, mirroring the :forward_request two-phase model. The worker replies directly to from with {:ok, %Channel{}, ref} or {:error, term}.

start_link(opts)

@spec start_link(keyword()) :: GenServer.on_start()

Starts the HTTP/3 pool coordinator.