View Source Reactor.Builder (reactor v0.2.1)
Build a new Reactor programmatically.
You don't have to use the Reactor DSL to create a Reactor. The functions in this module allow you to define a Reactor programmatically. This is especially useful if you need to create a reactor dynamically (maybe based on a UI such as React Flow).
example
Example
reactor = Builder.new()
{:ok, reactor} = Builder.add_input(reactor, :name)
argument = Argument.from_input(:name)
{:ok, reactor} = Builder.add_step(reactor, :greet, [argument])
{:ok, reactor} = Builder.return(reactor, :greet)
Link to this section Summary
Functions
Add a named input to the Reactor.
Add a step to the Reactor.
Build a new, empty Reactor.
Build a step which can be added to a reactor at runtime.
Specify the return value of the Reactor.
Link to this section Types
@type async?() :: {:async?, boolean()}
Should the step be run asynchronously?
@type max_retries() :: {:max_retries, :infinity | non_neg_integer()}
How many times is the step allowed to retry?
@type step_argument() :: Reactor.Argument.t() | {atom(), {:input | :result, any()}}
@type step_options() :: [async?() | max_retries()]
Link to this section Functions
Add a named input to the Reactor.
This both places the input in the Reactor for later input validation and adds steps to the Reactor which will emit and (possibly) transform the input.
@spec add_step( Reactor.t(), name :: any(), impl(), [step_argument()], step_options() ) :: {:ok, Reactor.t()} | {:error, any()}
Add a step to the Reactor.
Add a new step to the Reactor. Rewrites input arguments to use the result of the input steps and injects transformation steps as required.
@spec new() :: Reactor.t()
Build a new, empty Reactor.
@spec new_step(name :: any(), impl(), [step_argument()], step_options()) :: {:ok, Reactor.Step.t()} | {:error, any()}
Build a step which can be added to a reactor at runtime.
Note that the built step doesn't support argument transformations - you should
add an additional step to do the transformation needed (this is what
add_step/5
does anyway).
Specify the return value of the Reactor.
The return value must be the result of a completed step.