Quiver.Pool behaviour (quiver v0.2.0)

Copy Markdown View Source

Common interface for protocol-specific pool implementations.

Both Quiver.Pool.HTTP1 and Quiver.Pool.HTTP2 implement this behaviour, allowing Quiver.Pool.Manager to dispatch requests without knowing the underlying protocol.

Summary

Types

headers()

@type headers() :: Quiver.Conn.headers()

method()

@type method() :: Quiver.Conn.method()

Callbacks

request(pool, method, path, headers, body, opts)

@callback request(
  pool :: pid(),
  method(),
  path :: String.t(),
  headers(),
  body :: iodata() | nil,
  opts :: keyword()
) :: {:ok, Quiver.Response.t()} | {:error, term()}

stats(pool)

@callback stats(pool :: pid()) :: %{
  :idle => non_neg_integer(),
  :active => non_neg_integer(),
  :queued => non_neg_integer(),
  optional(:connections) => non_neg_integer()
}

stream_request(pool, method, path, headers, body, opts)

@callback stream_request(
  pool :: pid(),
  method(),
  path :: String.t(),
  headers(),
  body :: iodata() | nil,
  opts :: keyword()
) :: {:ok, Quiver.StreamResponse.t()} | {:error, term()}