@@ -1142,7 +1142,7 @@ pub struct WorkflowOptions {
11421142/// The overall semantics of Priority are:
11431143/// (more will be added here later)
11441144/// 1. First, consider "priority_key": lower number goes first.
1145- #[ derive( Debug , Clone , Default , PartialEq , Eq ) ]
1145+ #[ derive( Debug , Clone , Default , PartialEq ) ]
11461146pub struct Priority {
11471147 /// Priority key is a positive integer from 1 to n, where smaller integers
11481148 /// correspond to higher priorities (tasks run sooner). In general, tasks in
@@ -1155,12 +1155,50 @@ pub struct Priority {
11551155 /// The default priority is (min+max)/2. With the default max of 5 and min of
11561156 /// 1, that comes out to 3.
11571157 pub priority_key : u32 ,
1158+
1159+ /// Fairness key is a short string that's used as a key for a fairness
1160+ /// balancing mechanism. It may correspond to a tenant id, or to a fixed
1161+ /// string like "high" or "low". The default is the empty string.
1162+ ///
1163+ /// The fairness mechanism attempts to dispatch tasks for a given key in
1164+ /// proportion to its weight. For example, using a thousand distinct tenant
1165+ /// ids, each with a weight of 1.0 (the default) will result in each tenant
1166+ /// getting a roughly equal share of task dispatch throughput.
1167+ ///
1168+ /// (Note: this does not imply equal share of worker capacity! Fairness
1169+ /// decisions are made based on queue statistics, not
1170+ /// current worker load.)
1171+ ///
1172+ /// As another example, using keys "high" and "low" with weight 9.0 and 1.0
1173+ /// respectively will prefer dispatching "high" tasks over "low" tasks at a
1174+ /// 9:1 ratio, while allowing either key to use all worker capacity if the
1175+ /// other is not present.
1176+ ///
1177+ /// All fairness mechanisms, including rate limits, are best-effort and
1178+ /// probabilistic. The results may not match what a "perfect" algorithm with
1179+ /// infinite resources would produce. The more unique keys are used, the less
1180+ /// accurate the results will be.
1181+ ///
1182+ /// Fairness keys are limited to 64 bytes.
1183+ pub fairness_key : String ,
1184+
1185+ /// Fairness weight for a task can come from multiple sources for
1186+ /// flexibility. From highest to lowest precedence:
1187+ /// 1. Weights for a small set of keys can be overridden in task queue
1188+ /// configuration with an API.
1189+ /// 2. It can be attached to the workflow/activity in this field.
1190+ /// 3. The default weight of 1.0 will be used.
1191+ ///
1192+ /// Weight values are clamped by the server to the range [0.001, 1000].
1193+ pub fairness_weight : f32 ,
11581194}
11591195
11601196impl From < Priority > for common:: v1:: Priority {
11611197 fn from ( priority : Priority ) -> Self {
11621198 common:: v1:: Priority {
11631199 priority_key : priority. priority_key as i32 ,
1200+ fairness_key : priority. fairness_key ,
1201+ fairness_weight : priority. fairness_weight ,
11641202 }
11651203 }
11661204}
@@ -1169,6 +1207,8 @@ impl From<common::v1::Priority> for Priority {
11691207 fn from ( priority : common:: v1:: Priority ) -> Self {
11701208 Self {
11711209 priority_key : priority. priority_key as u32 ,
1210+ fairness_key : priority. fairness_key ,
1211+ fairness_weight : priority. fairness_weight ,
11721212 }
11731213 }
11741214}
0 commit comments