Implementers of vise
should interface with the system using the engine
module.
The engine comes in two implementations, one volatile base implemetnation and a subclass that includes persistent state.
The engine
module provides three different modes of operation for the engine implementations.
Directly interaction with an engine.Engine
instance.
The engine is manually initialized, and execution must be explicitly triggered with input every time the VM yields control.
Output flushing must also be operated manually.
The interface is the same for both persistent and volatile operation.
Receives input from a reader and writes into to a writer, and executes the underlying engine.Engine
with given inputs until execution is terminated.
The loop may be either persistent or volatile.
This mode drives the interactive driver execution tool.
Compatible with e.g. a network socket or HTTP frontend. The engine.RunPersisted
method restores a persisted state and runs one single input until VM yield after which the new state is persisted.
This mode of operation can only be used with persistent state.
The engine configuration defines the top-level parameters for the execution environment, including maximum output size, default language, execution entry point and more.
Please refer to engine.Config
for details.
The engine.Config.SessionId
is used to disambiguate the end-user that is interacting with the engine.
For example, in a USSD context, the SessionId
may be the phone number of the end-user.
The engine stores the SessionId
aswell as the current chosen lang.Language
in the execution context. This is passed through to the VM operation, and is available for client code, specifically:
LOAD
. (resource.EntryFunc
).
resource.Resource.GetMenu
).
resource.Resource.GetTemplate
).