Priority contains metadata that controls relative ordering of task processing when tasks are backlogged in a queue. Initially, Priority will be used in activity and workflow task queues, which are typically where backlogs exist.
Priority is (for now) attached to workflows and activities. Activities and child workflows inherit Priority from the workflow that created them, but may override fields when they are started or modified. For each field of a Priority on an activity/workflow, not present or equal to zero/empty string means to inherit the value from the calling workflow, or if there is no calling workflow, then use the default (documented on the field).
The overall semantics of Priority are: 1. First, consider "priority_key": lower number goes first. 2. Then consider "fairness_key" and "fairness_weight" for fairness balancing.
Method | __post |
Validates priority settings. |
Class Variable | default |
Singleton default priority instance. |
Class Variable | fairness |
A short string (max 64 bytes) that is used as a key for a fairness balancing mechanism. This can correspond to a tenant id or even fixed strings like "high", "low", etc. |
Class Variable | fairness |
A float that represents the weight for task dispatch for the associated fairness key. Tasks for a fairness key are dispatched in proportion to their weight. |
Class Variable | priority |
Priority key is a positive integer from 1 to n, where smaller integers correspond to higher priorities (tasks run sooner). In general, tasks in a queue should be processed in close to priority order, although small deviations are possible. |
Static Method | _from |
Create a Priority instance from the proto object. |
Method | _to |
Undocumented |
A short string (max 64 bytes) that is used as a key for a fairness balancing mechanism. This can correspond to a tenant id or even fixed strings like "high", "low", etc.
The fairness mechanism attempts to dispatch tasks for a given key in proportion to its weight. For example, using a thousand distinct tenant ids, each with a weight of 1.0 will result in each tenant getting a roughly equal share of task dispatch throughput.
Default is an empty string.
A float that represents the weight for task dispatch for the associated fairness key. Tasks for a fairness key are dispatched in proportion to their weight.
Server will clamp the values between 0.001 and 1000. Default weight is 1.0.
The effective weight of a task is determined by the following precedence (highest to lowest): 1. Weights overridden in task queue configuration 2. Weights attached to workflow/activity 3. Default weight of 1.0
Priority key is a positive integer from 1 to n, where smaller integers correspond to higher priorities (tasks run sooner). In general, tasks in a queue should be processed in close to priority order, although small deviations are possible.
The maximum priority value (minimum priority) is determined by server configuration, and defaults to 5.
The default priority is (min+max)/2. With the default max of 5 and min of 1, that comes out to 3.