Variables

Variables are value handled by osp-variables plugin. They allow for both read and write by multiple source. This allow users to interact with OnSphere directly from front-end for example. The results can be used to trigger callbacks.

Persistent value

A persisted variable is stored upon modification or initialization if a default is define.

The persistence is defined on the owner.variables.

Default value

A default value is published when the module starts. This default is defined on the owner.variables. For a persisted variable, the default is only published once when the variable is created for the first time. Then only the content of the persistence store is published.

Variable publishing

Startup

At startup, the osp-variables plugin loads from disk all variables that were previously persisted and publishes those values with the RETRANSMISSION transmission mode. See persistent storage to understand how to configure a persisted volume.

The whole store is loaded before the first variable is published. A persisted variable therefore publishes its stored content after a restart, and its default only when nothing is stored for it yet.

Warning

If the store file cannot be read, the module tries 5 times, one second apart, then starts without the persisted contents. The persisted variables then publish their default, and the file is rewritten at the next modification.

A persisted variable is initialized with the default value during the first start.

Note

If a variable which no longer requires persistence is found on the disk, it is automatically erased to avoid potential ghost persisted values.

Modified value

When the plugin receives a write request for a variable that it holds, it will store the variable content (potentially on the disk, if persistence is enabled) and publish the value with the CHANGE transmission mode.

When the plugin receives a read request for a variable that it holds, it will fetch the variable current content and publish the value with the RETRANSMISSION transmission mode.

Conversion

When a variable type does not match with the content type, the module will automatically try to apply a conversion to get the proper type.