View Source K8s.Client.Mint.ConnectionRegistry (k8s v2.4.2)

A registry for open connections. As HTTP/2 allows simultaneous requests, we handle multiple requests with one process. In this case, the registry stores the PID of the HTTPAdapter which is connected according to the given connection details (URI/opts).

HTTP/1 only allows one request per connection at a time. In order to support simultaneous requests, we need a connection pool. This is where the :poolboy library comes in.

Summary

Functions

ets a HTTPAdapter process from the registry.

Returns a specification to start this module under a supervisor.

Starts the registry.

Types

@type adapter_pool_t() :: %{adapter: pid(), pool: pid() | nil}
@type adapter_type_t() :: :adapter_pool | :singleton
@type uriopts() :: {URI.t(), keyword()}

Functions

@spec checkin(adapter_pool_t()) :: :ok
@spec checkout(uriopts()) ::
  {:ok, adapter_pool_t()} | {:error, K8s.Client.HTTPError.t()}

ets a HTTPAdapter process from the registry.

If the returned process is an adapter pool, an adapter is checked out from the pool and a map with both PIDs is returned.

If the returned process is an adapter process, a map with its PID and pool set to nil is returned.

Returns a specification to start this module under a supervisor.

See Supervisor.

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

Starts the registry.