Worker attribute sets and worker requirement sets
The worker_attribute_set
field of the bridge configuration
describes the worker’s capabilities.
t
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 workA
andB
- Worker
w2
states that it can perform workB
andC
Let’s look at the following components’ worker requirement sets and how they can be satisfied:
Component
c1
requires a worker which can perform workA
. Only workerw1
satisfies this requirement set: workerw2
cannot perform workA
.Component
c2
requires a worker which can perform workB
andC
. Only workerw2
satisfies this requirement set: workerw1
cannot perform workC
.Component
c3
requires a worker which can perform either workA
andB
or workC
. Both workers satisfy this requirement set: workerw1
can perform workA
andB
and thus satisfies the requirement set, and workerw2
also satisfies the requirement set because it can perform workC
.Component
c4
requires a worker which can perform workerA
and workC
. Neither workerw1
nor workerw2
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.
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.