Get SpatialOS

Sites

Menu

Worker attribute sets and worker requirement sets

The workerAttributeSet field of the bridge configuration describes the worker’s capabilities.

Overview and terminology

An attribute describes an ability to do a particular kind of work. A worker attribute set describes a worker’s overall capability to do work. A worker requirement set represents what is required of a worker to perform a certain kind of work. Worker attribute set and worker requirement sets are related as follows: a worker attribute set either satisfies a worker requirement set or it does not satisfy it.

We can specify a worker requirement set for a component. SpatialOS uses this requirement set to grant an appropriate worker write access on the component. It does so by checking if any of the workers it knows about has a worker attribute set that satisfies the requirement set associated with that component.

Similarly, we can specify a worker requirement set for an entity. SpatialOS uses this requirement set to grant appropriate workers read access on the entity.

Consider the following abstract example:

  • Worker w1 states that it can perform work A and B
  • Worker w2 states that it can perform work B and C

Let’s look at the following components’ worker requirement sets and how they can be satisfied:

  • Component c1 requires a worker which can perform work A. Only worker w1 satisfies this requirement set: worker w2 cannot perform work A.

  • Component c2 requires a worker which can perform work B and C. Only worker w2 satisfies this requirement set: worker w1 cannot perform work C.

  • Component c3 requires a worker which can perform either work A and B or work C. Both workers satisfy this requirement set: worker w1 can perform work A and B and thus satisfies the requirement set, and worker w2 also satisfies the requirement set because it can perform work C.

  • Component c4 requires a worker which can perform worker A and work C. Neither worker w1 nor worker w2 can satisfy this requirement set.

Specifying worker attribute set

Concretely, the workerAttributeSet field is a list of strings. Each string defines a capability. For example, a UnityWorker may have the following attribute set:

"workerAttributeSet": {
    "attributes": ["physics"]
}

With this workerAttributeSet setting, the worker indicates that it can perform “physics” work.

In addition to the attributes specified in your worker configuration file, each worker instance will have a unique attribute associated with it, assigned by SpatialOS when the worker connects. This allows users to specify write access over entity components with a requirement set that can only be matched by a specific worker instance.

In C++, C#, and Java, the only way to obtain the worker’s unique attribute is by reading the worker attributes associated with a command request sent from that worker. Please refer to the language-specific API documentation for more details.

Was this page helpful?

Thanks for letting us know!

Thanks for your feedback

Need more help? Ask on the forums