Worker flags

Define worker flags at launch

Worker instances in a deployment have access to worker flags associated with their worker type. You use the launch configuration file (see the structured project layout or flexible project layout documentation) to define worker flags and their values. Each worker flag is defined by a name and an initial value. All worker flag values are strings.

Worker instances of a particular type in a deployment have access to the same set of flags containing the same values.

Worker flag names cannot contain periods (full stops).

Naming conventions

Example

{
   ...
   "workers": [
      {
         "worker_type": "MyWorkerType",
         "flags": [
             {
                 "name": "mycompany_theproject_work_speed",
                 "value": "15"
             }
         ]
      }
   ]
   ...
}

In the example above, instances of worker type MyWorkerType can access the value of the worker flag called mycompany_theproject_work_speed. The value of the worker flag when the deployment starts is 15, although its value can change during runtime.

Read worker flag values

A worker instance can query the value of a worker flag at any time. This is a local, synchronous operation, which always returns the most up-to-date value for the worker flag.

The initial values for the worker flags are available on a worker instance as soon as the connection between it and the SpatialOS Runtime is established. If the SpatialOS Runtime fails to provide the worker flag values, the worker instance logs an error and disconnects from the SpatialOS Runtime.

For details, see the API documentation: C++, C#, Java.

Change worker flag values during runtime

You can add and remove worker flags, and change their values.

  • For a cloud deployment: in the Worker flags tab of your deployment page in the SpatialOS Console (outside of China/in China).
  • For a local deployment: using the CLI for a local deployment.

Watch for worker flag changes

You can watch for worker flag changes using the callback OnFlagUpdate. See the Dispatcher Callbacks table for C++, C#, or Java.

Updated 6 months ago


Worker flags


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.