Jido.Agent.Server (Jido v1.1.0-rc.2)
View SourceGenServer implementation for managing agent processes.
This server handles the lifecycle and runtime execution of agents, including:
- Agent initialization and startup
- Signal processing and routing
- State management and transitions
- Child process supervision
- Graceful shutdown
The server can be started in different modes (:auto
or :manual
) and supports
both synchronous (call) and asynchronous (cast) signal handling.
Summary
Functions
Sends a synchronous signal to an agent and waits for the response.
Sends an asynchronous signal to an agent.
Returns a child specification for starting the server under a supervisor.
Starts a new agent server process.
Gets the current state of an agent.
Returns a via tuple for process registration.
Types
@type start_option() :: {:id, String.t()} | {:agent, module() | struct()} | {:initial_state, map()} | {:registry, module()} | {:mode, :auto | :manual} | {:dispatch, pid() | {module(), term()}} | {:log_level, Logger.level()} | {:max_queue_size, non_neg_integer()}
Functions
@spec call( pid() | atom() | {atom(), node()}, Jido.Signal.t() | Jido.Instruction.t(), timeout() ) :: {:ok, Jido.Signal.t()} | {:error, term()}
Sends a synchronous signal to an agent and waits for the response.
@spec cast(pid() | atom() | {atom(), node()}, Jido.Signal.t() | Jido.Instruction.t()) :: {:ok, String.t()} | {:error, term()}
Sends an asynchronous signal to an agent.
@spec child_spec(keyword()) :: Supervisor.child_spec()
Returns a child specification for starting the server under a supervisor.
@spec start_link([start_option()]) :: GenServer.on_start()
Starts a new agent server process.
Options
:id
- Unique identifier for the agent (auto-generated if not provided):agent
- Agent module or struct to be managed:initial_state
- Initial state map for the agent:registry
- Registry for process registration:mode
- Operation mode (:auto
or:manual
):routes
- Routes for the agent:output
- Output destination for agent signals:log_level
- Logging level:max_queue_size
- Maximum size of pending signals queue
Returns
{:ok, pid}
- Successfully started server process{:error, reason}
- Failed to start server
@spec state(pid() | atom() | {atom(), node()}) :: {:ok, Jido.Agent.Server.State.t()} | {:error, term()}
Gets the current state of an agent.
Returns a via tuple for process registration.