Normandy.Options (normandy v2.2.0)

View Source

Option validation for Normandy's public entry points.

An entry point keeps a NimbleOptions schema and calls validate!/3 with its own {module, function, arity}. Options may be a keyword list or a map with atom keys. Any problem raises ArgumentError whose message starts with Module.function/arity: and names the option:

Normandy.Agents.BaseAgent.init/1: unknown option :api_kye; supported: :client, :model, ...

The value of an option named in sensitive_keys/0, or nested under one, never appears in a message: the message names the option and shows its :type_doc instead. Give every such option a :type_doc in its schema. Whatever the option, a map, list or tuple value is never echoed either (it can hold a secret under any key): the message states its type, for example got: a map. Scalar values appear as NimbleOptions words them.

Timeouts

Every option a caller waits on is called :timeout and takes ms or :infinity, except the durable server's two _ms options (not waits on a call; they also take ms or :infinity) and the Mnesia stores' :wait_timeout (ms or :infinity, as :mnesia.wait_for_tables/2). A :timeout that bounds one tool call takes positive ms only: a tool call is always bounded. Defaults:

OptionWhereDefault
:timeoutAgentProcess.run/3:infinity
:timeoutAgentProcess.update_agent/3:infinity
:timeoutAgentPool.checkout/2, AgentPool.transaction/35_000
:timeoutReactive.race/3, all/3, some/360_000
:timeoutParallelOrchestrator.execute/3, execute_stream/2300_000 per agent
:timeoutBatch.Processor.process_batch/3 and its variants, BaseAgent.process_batch/3300_000 per item
:timeout (positive ms)Toolset.register/3, BaseAgent.register_tool/3, DSL tool Mod, timeout: msthe tool call's timeout; unset: 30_000 (Tools.Executor.default_timeout/0)
:timeout (positive ms)Tools.Executor.execute_tool/2, execute_tool_classified/230_000 (the dispatcher passes the registration timeout)
:timeout (positive ms)A2A.Registry.discover_and_register/360_000 (each registered tool's timeout)
:approval_timeout_msTurn.Server.start_link/1300_000
:idle_timeout_msTurn.Server.start_link/160_000
:wait_timeoutSessionStore.Mnesia.create_tables/1, MemoryStore.Mnesia.create_tables/130_000
(none)Turn.Server.run/2:infinity

CircuitBreaker.start_link/1's :timeout (60_000) is how long an open breaker waits before it lets probe calls through, not a call timeout.

Summary

Functions

The Markdown option list for schema, to embed in an @doc.

Option names whose values are never shown in an error message.

Validates opts against schema and returns them as a keyword list with the schema's defaults filled in.

Functions

docs(schema)

@spec docs(NimbleOptions.t()) :: String.t()

The Markdown option list for schema, to embed in an @doc.

sensitive_keys()

@spec sensitive_keys() :: [atom()]

Option names whose values are never shown in an error message.

validate!(opts, schema, arg)

@spec validate!(keyword() | map(), NimbleOptions.t(), {module(), atom(), arity()}) ::
  keyword()

Validates opts against schema and returns them as a keyword list with the schema's defaults filled in.

Raises ArgumentError prefixed with Module.function/arity: (from mfa) for an unknown or duplicated option, a missing required one, a bad value, or opts that are neither a keyword list nor a map with atom keys.