Zizq.Config (Zizq v0.6.0)

Copy Markdown View Source

Validated configuration for a running Zizq client.

Built once when the client starts and read on every request, so it is kept in :persistent_term rather than behind a process. A lookup is then a direct memory read with no message pass on the hot path.

Summary

Functions

Remove a stored config, so repeated start/stop cycles don't accumulate.

Look up the config for a running client.

Validate raw options and build a config struct.

Store the config for name. Called by the supervisor at startup.

The base URL as a string, for logs and messages.

Types

t()

@type t() :: %Zizq.Config{
  codec: Zizq.Codec.t(),
  connect_timeout: timeout(),
  finch_name: atom(),
  name: atom(),
  pool_count: pos_integer(),
  receive_timeout: timeout(),
  recorder: term(),
  stream_idle_timeout: timeout(),
  uri: URI.t()
}

Functions

delete(name)

@spec delete(atom()) :: boolean()

Remove a stored config, so repeated start/stop cycles don't accumulate.

fetch!(name)

@spec fetch!(atom()) :: t()

Look up the config for a running client.

Raises with an actionable message if the client isn't running, which is by far the most common way to get this wrong.

new!(opts)

@spec new!(keyword()) :: t()

Validate raw options and build a config struct.

Raises NimbleOptions.ValidationError on invalid options, or ArgumentError for a malformed URL or unknown codec.

put(config)

@spec put(t()) :: :ok

Store the config for name. Called by the supervisor at startup.

url(config)

@spec url(t()) :: String.t()

The base URL as a string, for logs and messages.