pub struct Priority {
pub priority_key: u32,
pub fairness_key: String,
pub fairness_weight: f32,
}
Expand description
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. Other queues in the server (such as transfer and timer queues) and rate limiting decisions do not use Priority, but may in the future.
Priority is 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 below).
Despite being named “Priority”, this message will also contains fields that control “fairness” mechanisms.
The overall semantics of Priority are: (more will be added here later)
- First, consider “priority_key”: lower number goes first.
Fields§
§priority_key: u32
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.
fairness_key: String
Fairness key is a short string that’s used as a key for a fairness balancing mechanism. It may correspond to a tenant id, or to a fixed string like “high” or “low”. The default is the empty string.
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 (the default) will result in each tenant getting a roughly equal share of task dispatch throughput.
(Note: this does not imply equal share of worker capacity! Fairness decisions are made based on queue statistics, not current worker load.)
As another example, using keys “high” and “low” with weight 9.0 and 1.0 respectively will prefer dispatching “high” tasks over “low” tasks at a 9:1 ratio, while allowing either key to use all worker capacity if the other is not present.
All fairness mechanisms, including rate limits, are best-effort and probabilistic. The results may not match what a “perfect” algorithm with infinite resources would produce. The more unique keys are used, the less accurate the results will be.
Fairness keys are limited to 64 bytes.
fairness_weight: f32
Fairness weight for a task can come from multiple sources for flexibility. From highest to lowest precedence:
- Weights for a small set of keys can be overridden in task queue configuration with an API.
- It can be attached to the workflow/activity in this field.
- The default weight of 1.0 will be used.
Weight values are clamped by the server to the range [0.001, 1000].
Trait Implementations§
impl StructuralPartialEq for Priority
Auto Trait Implementations§
impl Freeze for Priority
impl RefUnwindSafe for Priority
impl Send for Priority
impl Sync for Priority
impl Unpin for Priority
impl UnwindSafe for Priority
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request