Get SpatialOS

Sites

Menu

Worker attribute sets and worker requirement sets

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

If you’re using the new load balancer (part of the new Runtime, available from SpatialOS version 13.4), use the worker_attribute_set field to specify the layer that this worker simulates. This must be a single string.

Overview and terminology

An attribute describes an ability to do a particular kind of work.

Definitions

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.

Example

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 a worker attribute set

Concretely, the worker_attribute_set field is a list of strings. Each string defines a capability.

If you’re using the new load balancer (part of the new Runtime, available from SpatialOS version 13.4), use the worker_attribute_set field to specify the layer that this worker simulates. This must be a single string.

For example, a UnityWorker may have the following attribute set:

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

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

Worker ID

In addition to the attributes specified in your worker configuration file (worker.json), 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 SDK-specific API documentation for more details.

Search results

Was this page helpful?

Thanks for letting us know!

Thanks for your feedback

Need more help? Ask on the forums