View Source Jido.Runner behaviour (Jido v1.0.0)

Behavior for executing planned actions on an Agent.

Summary

Functions

Normalizes actions into a list of instruction tuples {module, map()}.

Types

action()

@type action() :: module() | {module(), map()}

Callbacks

run(agent, opts)

@callback run(agent :: struct(), opts :: keyword()) ::
  {:ok, struct()} | {:error, Jido.Error.t()}

Functions

normalize_instructions(input)

@spec normalize_instructions(action() | [action()]) :: [{module(), map()}]

Normalizes actions into a list of instruction tuples {module, map()}.

Accepts: • A single action module • A single action tuple {module, map()} • A list of modules • A list of action tuples {module, map()}

Examples

iex> normalize_instructions(MyAction)
[{MyAction, %{}}]

iex> normalize_instructions({MyAction, %{foo: :bar}})
[{MyAction, %{foo: :bar}}]

iex> normalize_instructions([MyAction1, MyAction2])
[{MyAction1, %{}}, {MyAction2, %{}}]

iex> normalize_instructions([{MyAction1, %{a: 1}}, {MyAction2, %{b: 2}}])
[{MyAction1, %{a: 1}}, {MyAction2, %{b: 2}}]