Runbox.Runtime.Stage.Sandbox (runbox v0.1.0)
Sandbox is helper for executing runs without started Altworx application.
Sandbox can be used for scenarios unit testing and also for interactive
development of scenarios. When used for unit testing, it can be used
directly or via Runbox.Runtime.Stage.Sandbox.TestRunner
.
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
fuctions to execute your runs (of course use recompile
before run execution if you
changed scenario code).
Link to this section Summary
Functions
Starts new run for scenario_id
and waits until all input messages are processed.
Link to this section Types
topic_name()
@type topic_name() :: String.t()
topics()
@type topics() :: %{required(topic_name()) => [Toolbox.Message.t()]}
Link to this section Functions
execute_run(topics, scenario_id, modules \\ nil)
@spec execute_run(topics(), String.t(), [module()] | nil) :: {:ok, Toolbox.Scenario.OutputAction.t()} | {:error, term()}
Starts new run for scenario_id
and waits until all input messages are processed.
Returns all output actions generated by run execution. Input messages for each runtime
topic used by scenario should be defined in topics
argument. Undefined topics are
considered empty. Messages in each topic must be in ascending order by timestamp
.
Optionally user can specify list of modules
containing scenarios (manifests, templates). If
list of modules is specified execute_run
does not search scenario in :scenarios
application
release, but in given modules. It opens possibility to write ad-hoc scenarios with only
dependency on Runbox application, for example use it in Livebook.
To see example of such livebook just run livebook server --home .
in runbox root directory,
go to generated livebook server link in browser and finally open sandbox-scenario-demo.livemd
document. Running docker or altworx is not needed, only runbox app (and its deps) is required!