View Source Runbox.Runtime.Stage.TemplateImpl (runbox v21.2.0)
Module encapsulates scenario template callback calls.
Scenario defines Runbox.Runtime.Stage.Unit
as state carrier, these units are organized
into Runbox.Runtime.Stage.UnitRegistry
which is helper structure to route messages between
units managed by one template.
Messages are handled via Runbox.Scenario.Template.StageBased
callbacks. We distinguish two
types of messages = message to existing unit and message to new unit (asset discovery).
Messages that doesn't have any unit registered and thus found to handle them, we call this
situation asset discovery and use Runbox.Scenario.Template.StageBased.handle_asset_discovery/1
callback to handle these message. New unit may or may not be created here, but when it does,
it needs to be initialized via Runbox.Scenario.Template.StageBased.init/2
callback.
When there is at least one unit which is registered to the message, we use callback
Runbox.Scenario.Template.StageBased.handle_message/2
. Unit may be updated or stopped here.
We support timeouts to be defined. These timeouts are triggered via external
time, which is
derived from incoming message timestamps. Timeouts are registered for one unit.
Some output actions produced by any of template callback should be further updated. Events
require filling run id
and notifications require scenario id
to be filled.