Jido.Instruction (Jido Action v3.0.0-beta.12)

View Source

Defines the invocation value for one executable target.

An Instruction contains a target, params, context, and metadata. The target follows the Jido.Executable contract. It can contain an Action module, a Flow module, or a runtime Jido.Flow value.

Use :target for every executable kind. The removed :action, :flow, and :opts inputs return construction errors. Pass execution options directly to Jido.Exec.

%Jido.Instruction{
  target: MyApp.Actions.SendEmail,
  params: %{to: "user@example.com"},
  context: %{tenant_id: "tenant_123"},
  metadata: %{request_id: "req_123"}
}

The constructor resolves the target and validates the three invocation maps. It keeps the target value without conversion. Metadata has no execution meaning in this module.

Constructor maps are not a stored or JSON representation. Executable module atoms and runtime Flow values do not have one general JSON form.

Summary

Types

Caller-supplied execution context.

An Action module, Flow module, or runtime Flow value.

Caller metadata with no execution meaning.

Input parameters for the target.

t()

Call data for one executable target.

Functions

Creates an instruction from a map or keyword list.

Creates an instruction or raises on failure.

Types

context()

@type context() :: map()

Caller-supplied execution context.

executable_target()

@type executable_target() :: Jido.Executable.target()

An Action module, Flow module, or runtime Flow value.

metadata()

@type metadata() :: map()

Caller metadata with no execution meaning.

params()

@type params() :: map()

Input parameters for the target.

t()

@type t() :: %Jido.Instruction{
  context: map(),
  metadata: map(),
  params: map(),
  target: nil | any()
}

Call data for one executable target.

Functions

new(attrs)

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

Creates an instruction from a map or keyword list.

:target identifies an Action module, Flow module, or runtime Flow value. :params, :context, and :metadata are optional maps or keyword lists. A nil invocation map becomes an empty map.

The removed :id, :action, :flow, and :opts keys return an error, including when their values are nil or empty. Use :target for the executable, :metadata for descriptive identity, and Jido.Exec options for execution policy.

new!(attrs)

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

Creates an instruction or raises on failure.