Defines a processing workflow (Recipe).
A Recipe is essentially a collection of Orchid.Steps that describes a
Directed Acyclic Graph (DAG) of data processing.
It holds the definition of what needs to be done, but not the execution state.
Example
steps = [
{MySteps.Download, :url, :raw_html},
{MySteps.Parse, :raw_html, :data}
]
recipe = Orchid.Recipe.new(steps, name: :scraper_flow)Options
:name- The name of the recipe (atom).
Summary
Functions
Injects options into steps globally (supports deep traversal).
Creates a new Recipe.
Statically validates the steps within a recipe.
Performs a deep traversal on a list of steps.
Types
@type t() :: %Orchid.Recipe{ name: atom() | nil, opts: keyword(), steps: [Orchid.Step.t()] }
Functions
@spec assign_options( t(), Orchid.Step.implementation() | (Orchid.Step.t() -> boolean()) | :all, keyword() | %{} | (Orchid.Step.t() -> Orchid.Step.t()) ) :: t()
Injects options into steps globally (supports deep traversal).
This function allows you to modify the configuration of specific steps within a recipe, including steps inside nested recipes.
Selectors
The selector determines which steps will receive the new_opts:
:all- Matches every step.module(atom) - Matches steps implemented by this specific module.function(arity 2) - Matches steps implemented by this specific function reference.predicate function(fn step -> boolean()) - A custom function that receives the step and returnstrueif it should be modified.
@spec new( [Orchid.Step.t()], keyword() ) :: t()
Creates a new Recipe.
Arguments
steps- A list ofOrchid.Stepdefinitions.opts- Keyword options (e.g.,name: :my_recipe).
@spec validate_steps([Orchid.Step.t()], [Orchid.Step.io_key()]) :: :ok | {:error, term()}
Statically validates the steps within a recipe.
It performs the following checks:
- Option Validation: Calls
Step.validate_options/1for each step. - Missing Inputs: Checks if all steps have their required input keys satisfied (either by initial params or previous steps).
- Cyclic Dependencies: Checks if the graph contains any cycles.
@spec walk( [Orchid.Step.t()] | [{Orchid.Step.t(), non_neg_integer()}], (Orchid.Step.t() -> Orchid.Step.t()) | (t() -> t()), :step | :inner_recipe ) :: [Orchid.Step.t()]
Performs a deep traversal on a list of steps.
This function applies func to every step in the tree. If a step is a NestedStep
or its contains an inner recipe(with NestedStep.nested_check/1 returned true),
it recursively traverses the inner steps as well.
It supports both standard step lists and indexed step lists (used by Orchid.Scheduler).
Modes
:step(Default) - Thefuncreceives and modifies the Step definition.:inner_recipe- Thefuncreceives and modifies the Inner Recipe struct of a nested step.