Reactor.Builder.Recurse (reactor v0.15.6)

View Source

Handle recursive execution of Reactors for the builder.

This module provides functionality to recursively execute a reactor, with the output of each iteration becoming the input of the next one.

You should not use this module directly, but instead use Reactor.Builder.recurse/4.

Summary

Functions

Verify that the reactor has compatible inputs and outputs for recursion.

Functions

recurse(reactor, name, inner_reactor, arguments, options)

@spec recurse(
  Reactor.t(),
  atom(),
  Reactor.t() | module(),
  [Reactor.Builder.step_argument()],
  keyword()
) ::
  {:ok, Reactor.t()} | {:error, any()}

Execute a Reactor recursively.

Options

  • :guards (list of value that implements the Reactor.Guard.Build protocol) - Any guards which need to be added to the generated step The default value is [].

  • :async? (boolean/0) - Whether the nested Reactor is allowed to run async or not The default value is true.

  • :max_iterations (pos_integer/0) - Maximum number of iterations to execute

  • :exit_condition - Function to determine when to stop iteration

verify_io_compatibility(reactor)

@spec verify_io_compatibility(Reactor.t() | module()) ::
  :ok | {:error, {:incompatible_io, String.t()}}

Verify that the reactor has compatible inputs and outputs for recursion.

For recursion to work properly, the output type of the reactor must match its input type, so that the result of one iteration can be fed into the next.

This function checks:

  1. The reactor has a return value defined
  2. The output structure (as a map) contains all keys that are required as inputs