Agent-specific effect directives.
Each directive is a bare struct with a
Raxol.Core.Runtime.Directive.Executor protocol implementation that the
runtime invokes to perform the effect.
Built-in directives
| Directive | Effect |
|---|---|
Async | Spawn a task with a sender callback for multi-message replies |
Shell | Run a shell command via Port, return structured exit/output |
SendAgent | Route a message to another agent by id (via Registry) |
Re-exported from Raxol.Core.Runtime.Directive
These shared directives need no agent context; agent code can use them through this module's helpers for convenience or call the core module directly:
schedule/2- delegates toRaxol.Core.Runtime.Directive.schedule/2spawn/1- delegates toRaxol.Core.Runtime.Directive.spawn_task/1stop/1- delegates toRaxol.Core.Runtime.Directive.stop/1
Examples
Directive.async(fn sender ->
sender.({:progress, 50})
sender.({:done, do_work()})
end)
Directive.shell("ls -la", timeout: 5_000)
Directive.send_agent("worker-1", {:task, payload})Execution
Raxol.Core.Runtime.Directive.Executor.execute(directive, %{
pid: self(),
runtime_pid: runtime_pid
})Result messages arrive at context.pid as {:command_result, payload}.
Summary
Functions
Construct an Async directive with a sender-callback function.
Construct a SendAgent directive.
Construct a Shell directive.
Delegates to Raxol.Core.Runtime.Directive.spawn_task/1.
Delegates to Raxol.Core.Runtime.Directive.stop/1.
Types
Functions
@spec async((Raxol.Agent.Directive.Async.sender() -> any())) :: Raxol.Agent.Directive.Async.t()
Construct an Async directive with a sender-callback function.
@spec schedule(non_neg_integer(), term()) :: Raxol.Core.Runtime.Directive.Schedule.t()
Delegates to Raxol.Core.Runtime.Directive.schedule/2.
@spec send_agent(term(), term()) :: Raxol.Agent.Directive.SendAgent.t()
Construct a SendAgent directive.
@spec shell( String.t(), keyword() ) :: Raxol.Agent.Directive.Shell.t()
Construct a Shell directive.
Options:
:timeout- max execution time in ms (default: runtime default):cd- working directory:env- environment variables as[{key, value}]
@spec spawn((-> any())) :: Raxol.Core.Runtime.Directive.Spawn.t()
Delegates to Raxol.Core.Runtime.Directive.spawn_task/1.
@spec stop(term()) :: Raxol.Core.Runtime.Directive.Stop.t()
Delegates to Raxol.Core.Runtime.Directive.stop/1.