Encapsulates a complete Recipe as a standalone Step to implement nested operations.
This allows you to treat a complex sub-workflow as a single atomic step within a parent workflow.
Required Options
:recipe- The innerOrchid.Recipestruct to be executed.
Optional Options
:input_map- Parameter name mapping:%{parent_name => child_name}. Use this when the parent step input name differs from what the inner recipe expects.:output_map- Result name mapping:%{child_name => parent_name}. Use this to rename the inner recipe's output back to what the parent workflow expects.
The mapping direction follows the flow of data (Input: Parent -> Child; Output: Child -> Parent).
Examples
nested_step = {Orchid.Step.NestedStep,
:parent_param, :parent_result_param,
[
recipe: inner_recipe,
# Maps parent's :parent_param to child's :child_input
input_map: %{parent_param: :child_input},
# Maps child's :child_output back to :parent_result_param
output_map: %{child_output: :parent_result_param}
]
}Custom Nested Steps
If you need to define a custom step that behaves like a nested step (e.g., custom logic before/after the sub-recipe),
you must place the inner recipe in the :recipe option and implement nested?/0:
defmodule MyNested do
use Orchid.Step
# Tell the Scheduler to treat this as a nested step during traversals
# def nested?(), do: true
# use module attribute instead
@orchid_step_nested true
def run(input, opts) do
# ... custom logic ...
end
end
Summary
Functions
Checks if a given Step implementation or Step tuple represents a nested step.
Callback implementation for Orchid.Step.run/2.
Callback implementation for Orchid.Step.validate_options/1.
Functions
@spec nested_check(Orchid.Step.implementation() | Orchid.Step.t()) :: boolean()
Checks if a given Step implementation or Step tuple represents a nested step.
It's NestedStep-agnostic and also works for custom step implementations that define nested?/0.
@spec run(Orchid.Step.input(), Orchid.Step.step_options()) :: {:error, {:nested_step_execution_failed, term()}} | {:ok, Orchid.Step.output()}
Callback implementation for Orchid.Step.run/2.
Callback implementation for Orchid.Step.validate_options/1.