8 Using vise

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.

8.1 Modes of operation

The engine module provides three different modes of operation for the engine implementations.

8.1.1 Manual operation

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.

8.1.2 Synchronous loop

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.

8.1.3 Asynchronous one-shot

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.

8.2 Configuration

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.

8.3 Sessions

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.

8.4 Execution context

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: