View Source Runbox.Runtime.Sandbox behaviour (runbox v13.0.3)

Sandbox is a helper for executing runs without started Altworx application.

Sandbox can be used for scenarios unit testing and also for interactive development, e.g. in LiveBook.

This is a scenario-type agnostic version of Runbox.Runtime.Stage.Sandbox and Runbox.Runtime.Simple.Sandbox. This module will identify the type of the scenario and will route the request to the appropriate Sandbox implementation.

For interactive development of scenarios, run iex --erl "-runbox mode slave" -S mix from command line in your scenarios application root directory and then use Sandbox functions to execute your runs (of course use recompile before run execution if you changed scenario code).

Summary

Functions

Starts a new run for scenario_id and processes all input messages.

Types

@type opt() :: {:start_from, non_neg_integer()} | {:modules, [module()]}
@type opts() :: [opt()]
@type topic_name() :: String.t()
@type topics() :: %{required(topic_name()) => [Runbox.Message.t()]}

Callbacks

Link to this callback

execute_run(topics, scenario_id, list)

View Source
@callback execute_run(topics(), scenario_id :: String.t(), [
  opt() | {:scenario, Runbox.Scenario.t()}
]) ::
  {:ok, [Runbox.Scenario.OutputAction.t()]} | {:error, any()}

Functions

Link to this function

execute_run(topics, scenario_id, opts \\ [])

View Source
@spec execute_run(topics(), scenario_id :: String.t(), opts()) ::
  {:ok, [Runbox.Scenario.OutputAction.t()]} | {:error, any()}

Starts a new run for scenario_id and processes all input messages.

Returns all output actions generated by run execution. Input messages for each runtime topic, referenced by its logical name, are passed in the topics argument. Undefined topics are considered empty.

There are few options that can be specified.

  • :start_from - specify the start from value for the run. The value is used to filter out messages and is passed to the scenraio's init callback.
  • :modules - list of modules containing the scenario (manifest and template, which can be just one module). If not specified, modules are auto-discovered from the current Mix app. This opens up the possibility to write ad-hoc scenarios with only Runbox as dependency, e.g. in Livebook.