Jido.AgentServer.Options (Jido v2.0.0-rc.0)

View Source

Options for starting an AgentServer.

Internal Module

This module is internal to the AgentServer implementation. Its API may change without notice.

Validates and normalizes startup options including agent configuration, hierarchy settings, error policies, and dispatch configuration.

Summary

Functions

Creates validated Options from a keyword list or map.

Creates validated Options from a keyword list or map, raising on error.

Validates an error policy value.

Types

error_policy()

@type error_policy() ::
  :log_only
  | :stop_on_error
  | {:emit_signal, dispatch_cfg :: term()}
  | {:max_errors, pos_integer()}
  | (error :: term(), state :: map() -> {:ok, map()} | {:stop, term(), map()})

on_parent_death()

@type on_parent_death() :: :stop | :continue | :emit_orphan

t()

@type t() :: %Jido.AgentServer.Options{
  agent: any(),
  agent_module: atom(),
  default_dispatch: any(),
  error_policy: any(),
  id: binary(),
  idle_timeout: any(),
  initial_state: map(),
  jido: atom(),
  lifecycle_mod: atom(),
  max_queue_size: integer(),
  on_parent_death: atom(),
  parent: any(),
  persistence: any(),
  pool: atom(),
  pool_key: any(),
  registry: atom(),
  skip_schedules: boolean(),
  spawn_fun: any()
}

Functions

new(opts)

@spec new(keyword() | map()) :: {:ok, t()} | {:error, term()}

Creates validated Options from a keyword list or map.

Normalizes and validates all options, including:

  • Generating an ID if not provided
  • Validating the agent module/struct
  • Validating error policy
  • Parsing parent reference

Returns {:ok, options} or {:error, reason}.

new!(opts)

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

Creates validated Options from a keyword list or map, raising on error.

validate_error_policy(policy)

@spec validate_error_policy(term()) :: {:ok, error_policy()} | {:error, term()}

Validates an error policy value.