Skip to content

Commit 3400eb6

Browse files
dnrSushisourceychebotarevrodrigozhoucarlydf
authored
Merge initial protos for priority (#561)
**What changed?** Add initial protos for priority, enough to attach simple priority metadata to workflows and activities. See #513 for the full future plans, only the first field (priority_key) is included so far. **Why?** Control task ordering. **Server PR** Implementation on `priority` branch: temporalio/temporal@main...priority --------- Co-authored-by: Spencer Judge <[email protected]> Co-authored-by: Yuri <[email protected]> Co-authored-by: Rodrigo Zhou <[email protected]> Co-authored-by: Carly de Frondeville <[email protected]> Co-authored-by: Spencer Judge <[email protected]>
1 parent 9156239 commit 3400eb6

File tree

8 files changed

+192
-1
lines changed

8 files changed

+192
-1
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
SHELL=/bin/bash -o pipefail
1+
SHELL=bash -o pipefail
22

33
$(VERBOSE).SILENT:
44
############################# Main targets #############################

openapi/openapiv2.json

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7152,6 +7152,10 @@
71527152
"versioningOverride": {
71537153
"$ref": "#/definitions/v1VersioningOverride",
71547154
"description": "If set, takes precedence over the Versioning Behavior sent by the SDK on Workflow Task completion.\nTo unset the override after the workflow is running, use UpdateWorkflowExecutionOptions."
7155+
},
7156+
"priority": {
7157+
"$ref": "#/definitions/v1Priority",
7158+
"title": "Priority metadata"
71557159
}
71567160
}
71577161
},
@@ -7344,6 +7348,10 @@
73447348
"onConflictOptions": {
73457349
"$ref": "#/definitions/v1OnConflictOptions",
73467350
"description": "Defines actions to be done to the existing running workflow when the conflict policy\nWORKFLOW_ID_CONFLICT_POLICY_USE_EXISTING is used. If not set (ie., nil value) or set to a\nempty object (ie., all options with default value), it won't do anything to the existing\nrunning workflow. If set, it will add a history event to the running workflow."
7351+
},
7352+
"priority": {
7353+
"$ref": "#/definitions/v1Priority",
7354+
"title": "Priority metadata"
73477355
}
73487356
}
73497357
},
@@ -7992,6 +8000,10 @@
79928000
"useWorkflowBuildId": {
79938001
"type": "boolean",
79948002
"description": "If this is set, the activity would be assigned to the Build ID of the workflow. Otherwise,\nAssignment rules of the activity's Task Queue will be used to determine the Build ID."
8003+
},
8004+
"priority": {
8005+
"$ref": "#/definitions/v1Priority",
8006+
"description": "Priority metadata. If this message is not present, or any fields are not\npresent, they inherit the values from the workflow."
79958007
}
79968008
}
79978009
},
@@ -10642,6 +10654,10 @@
1064210654
"versioningOverride": {
1064310655
"$ref": "#/definitions/v1VersioningOverride",
1064410656
"description": "If set, takes precedence over the Versioning Behavior sent by the SDK on Workflow Task completion.\nTo unset the override after the workflow is running, use UpdateWorkflowExecutionOptions."
10657+
},
10658+
"priority": {
10659+
"$ref": "#/definitions/v1Priority",
10660+
"title": "Priority metadata"
1064510661
}
1064610662
},
1064710663
"description": "NewWorkflowExecutionInfo is a shared message that encapsulates all the\nrequired arguments to starting a workflow in different contexts."
@@ -11057,6 +11073,10 @@
1105711073
"lastWorkerDeploymentVersion": {
1105811074
"type": "string",
1105911075
"description": "The Worker Deployment Version this activity was dispatched to most recently."
11076+
},
11077+
"priority": {
11078+
"$ref": "#/definitions/v1Priority",
11079+
"title": "Priority metadata"
1106011080
}
1106111081
}
1106211082
},
@@ -11285,6 +11305,10 @@
1128511305
"pollerScalingDecision": {
1128611306
"$ref": "#/definitions/v1PollerScalingDecision",
1128711307
"description": "Server-advised information the SDK may use to adjust its poller count."
11308+
},
11309+
"priority": {
11310+
"$ref": "#/definitions/v1Priority",
11311+
"title": "Priority metadata"
1128811312
}
1128911313
}
1129011314
},
@@ -11440,6 +11464,17 @@
1144011464
},
1144111465
"description": "Attached to task responses to give hints to the SDK about how it may adjust its number of\npollers."
1144211466
},
11467+
"v1Priority": {
11468+
"type": "object",
11469+
"properties": {
11470+
"priorityKey": {
11471+
"type": "integer",
11472+
"format": "int32",
11473+
"description": "Priority key is a positive integer from 1 to n, where smaller integers\ncorrespond to higher priorities (tasks run sooner). In general, tasks in\na queue should be processed in close to priority order, although small\ndeviations are possible.\n\nThe maximum priority value (minimum priority) is determined by server\nconfiguration, and defaults to 5.\n\nThe default priority is (min+max)/2. With the default max of 5 and min of\n1, that comes out to 3."
11474+
}
11475+
},
11476+
"description": "Priority contains metadata that controls relative ordering of task processing\nwhen tasks are backlogged in a queue. Initially, Priority will be used in\nactivity and workflow task queues, which are typically where backlogs exist.\nOther queues in the server (such as transfer and timer queues) and rate\nlimiting decisions do not use Priority, but may in the future.\n\nPriority is attached to workflows and activities. Activities and child\nworkflows inherit Priority from the workflow that created them, but may\noverride fields when they are started or modified. For each field of a\nPriority on an activity/workflow, not present or equal to zero/empty string\nmeans to inherit the value from the calling workflow, or if there is no\ncalling workflow, then use the default (documented below).\n\nDespite being named \"Priority\", this message will also contains fields that\ncontrol \"fairness\" mechanisms.\n\nThe overall semantics of Priority are:\n1. First, consider \"priority_key\": lower number goes first.\n(more will be added here later)"
11477+
},
1144311478
"v1ProtocolMessageCommandAttributes": {
1144411479
"type": "object",
1144511480
"properties": {
@@ -12180,6 +12215,10 @@
1218012215
"useWorkflowBuildId": {
1218112216
"type": "boolean",
1218212217
"description": "If this is set, the activity would be assigned to the Build ID of the workflow. Otherwise,\nAssignment rules of the activity's Task Queue will be used to determine the Build ID."
12218+
},
12219+
"priority": {
12220+
"$ref": "#/definitions/v1Priority",
12221+
"description": "Priority metadata. If this message is not present, or any fields are not\npresent, they inherit the values from the workflow."
1218312222
}
1218412223
}
1218512224
},
@@ -12759,6 +12798,10 @@
1275912798
"inheritBuildId": {
1276012799
"type": "boolean",
1276112800
"description": "If this is set, the child workflow inherits the Build ID of the parent. Otherwise, the assignment\nrules of the child's Task Queue will be used to independently assign a Build ID to it."
12801+
},
12802+
"priority": {
12803+
"$ref": "#/definitions/v1Priority",
12804+
"description": "Priority metadata. If this message is not present, or any fields are not\npresent, they inherit the values from the workflow."
1276212805
}
1276312806
}
1276412807
},
@@ -12876,6 +12919,10 @@
1287612919
"inheritBuildId": {
1287712920
"type": "boolean",
1287812921
"description": "If this is set, the child workflow inherits the Build ID of the parent. Otherwise, the assignment\nrules of the child's Task Queue will be used to independently assign a Build ID to it."
12922+
},
12923+
"priority": {
12924+
"$ref": "#/definitions/v1Priority",
12925+
"title": "Priority metadata"
1287912926
}
1288012927
}
1288112928
},
@@ -13068,6 +13115,10 @@
1306813115
"onConflictOptions": {
1306913116
"$ref": "#/definitions/v1OnConflictOptions",
1307013117
"description": "Defines actions to be done to the existing running workflow when the conflict policy\nWORKFLOW_ID_CONFLICT_POLICY_USE_EXISTING is used. If not set (ie., nil value) or set to a\nempty object (ie., all options with default value), it won't do anything to the existing\nrunning workflow. If set, it will add a history event to the running workflow."
13118+
},
13119+
"priority": {
13120+
"$ref": "#/definitions/v1Priority",
13121+
"title": "Priority metadata"
1307113122
}
1307213123
}
1307313124
},
@@ -14314,6 +14365,10 @@
1431414365
"workerDeploymentName": {
1431514366
"type": "string",
1431614367
"description": "The name of Worker Deployment that completed the most recent workflow task.\nExperimental. Worker Deployments are experimental and might change in the future."
14368+
},
14369+
"priority": {
14370+
"$ref": "#/definitions/v1Priority",
14371+
"title": "Priority metadata"
1431714372
}
1431814373
},
1431914374
"description": "Hold basic information about a workflow execution.\nThis structure is a part of visibility, and thus contain a limited subset of information."
@@ -14516,6 +14571,10 @@
1451614571
"parentPinnedWorkerDeploymentVersion": {
1451714572
"type": "string",
1451814573
"description": "When present, it means this is a child workflow of a parent that is Pinned to this Worker\nDeployment Version. In this case, child workflow will start as Pinned to this Version instead\nof starting on the Current Version of its Task Queue.\nThis is set only if the child workflow is starting on a Task Queue belonging to the same\nWorker Deployment Version."
14574+
},
14575+
"priority": {
14576+
"$ref": "#/definitions/v1Priority",
14577+
"title": "Priority metadata"
1451914578
}
1452014579
},
1452114580
"title": "Always the first event in workflow history"

openapi/openapiv3.yaml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5747,6 +5747,12 @@ components:
57475747
description: |-
57485748
If this is set, the activity would be assigned to the Build ID of the workflow. Otherwise,
57495749
Assignment rules of the activity's Task Queue will be used to determine the Build ID.
5750+
priority:
5751+
allOf:
5752+
- $ref: '#/components/schemas/Priority'
5753+
description: |-
5754+
Priority metadata. If this message is not present, or any fields are not
5755+
present, they inherit the values from the workflow.
57505756
ActivityTaskStartedEventAttributes:
57515757
type: object
57525758
properties:
@@ -7967,6 +7973,10 @@ components:
79677973
description: |-
79687974
If set, takes precedence over the Versioning Behavior sent by the SDK on Workflow Task completion.
79697975
To unset the override after the workflow is running, use UpdateWorkflowExecutionOptions.
7976+
priority:
7977+
allOf:
7978+
- $ref: '#/components/schemas/Priority'
7979+
description: Priority metadata
79707980
description: |-
79717981
NewWorkflowExecutionInfo is a shared message that encapsulates all the
79727982
required arguments to starting a workflow in different contexts.
@@ -8359,6 +8369,10 @@ components:
83598369
lastWorkerDeploymentVersion:
83608370
type: string
83618371
description: The Worker Deployment Version this activity was dispatched to most recently.
8372+
priority:
8373+
allOf:
8374+
- $ref: '#/components/schemas/Priority'
8375+
description: Priority metadata
83628376
PendingChildExecutionInfo:
83638377
type: object
83648378
properties:
@@ -8608,6 +8622,43 @@ components:
86088622
description: |-
86098623
Attached to task responses to give hints to the SDK about how it may adjust its number of
86108624
pollers.
8625+
Priority:
8626+
type: object
8627+
properties:
8628+
priorityKey:
8629+
type: integer
8630+
description: |-
8631+
Priority key is a positive integer from 1 to n, where smaller integers
8632+
correspond to higher priorities (tasks run sooner). In general, tasks in
8633+
a queue should be processed in close to priority order, although small
8634+
deviations are possible.
8635+
8636+
The maximum priority value (minimum priority) is determined by server
8637+
configuration, and defaults to 5.
8638+
8639+
The default priority is (min+max)/2. With the default max of 5 and min of
8640+
1, that comes out to 3.
8641+
format: int32
8642+
description: |-
8643+
Priority contains metadata that controls relative ordering of task processing
8644+
when tasks are backlogged in a queue. Initially, Priority will be used in
8645+
activity and workflow task queues, which are typically where backlogs exist.
8646+
Other queues in the server (such as transfer and timer queues) and rate
8647+
limiting decisions do not use Priority, but may in the future.
8648+
8649+
Priority is attached to workflows and activities. Activities and child
8650+
workflows inherit Priority from the workflow that created them, but may
8651+
override fields when they are started or modified. For each field of a
8652+
Priority on an activity/workflow, not present or equal to zero/empty string
8653+
means to inherit the value from the calling workflow, or if there is no
8654+
calling workflow, then use the default (documented below).
8655+
8656+
Despite being named "Priority", this message will also contains fields that
8657+
control "fairness" mechanisms.
8658+
8659+
The overall semantics of Priority are:
8660+
1. First, consider "priority_key": lower number goes first.
8661+
(more will be added here later)
86118662
QueryRejected:
86128663
type: object
86138664
properties:
@@ -10053,6 +10104,10 @@ components:
1005310104
description: |-
1005410105
If set, takes precedence over the Versioning Behavior sent by the SDK on Workflow Task completion.
1005510106
To unset the override after the workflow is running, use UpdateWorkflowExecutionOptions.
10107+
priority:
10108+
allOf:
10109+
- $ref: '#/components/schemas/Priority'
10110+
description: Priority metadata
1005610111
SignalWithStartWorkflowExecutionResponse:
1005710112
type: object
1005810113
properties:
@@ -10251,6 +10306,10 @@ components:
1025110306
description: |-
1025210307
If this is set, the child workflow inherits the Build ID of the parent. Otherwise, the assignment
1025310308
rules of the child's Task Queue will be used to independently assign a Build ID to it.
10309+
priority:
10310+
allOf:
10311+
- $ref: '#/components/schemas/Priority'
10312+
description: Priority metadata
1025410313
StartWorkflowExecutionRequest:
1025510314
type: object
1025610315
properties:
@@ -10382,6 +10441,10 @@ components:
1038210441
WORKFLOW_ID_CONFLICT_POLICY_USE_EXISTING is used. If not set (ie., nil value) or set to a
1038310442
empty object (ie., all options with default value), it won't do anything to the existing
1038410443
running workflow. If set, it will add a history event to the running workflow.
10444+
priority:
10445+
allOf:
10446+
- $ref: '#/components/schemas/Priority'
10447+
description: Priority metadata
1038510448
StartWorkflowExecutionResponse:
1038610449
type: object
1038710450
properties:
@@ -11791,6 +11854,10 @@ components:
1179111854
description: |-
1179211855
The name of Worker Deployment that completed the most recent workflow task.
1179311856
Experimental. Worker Deployments are experimental and might change in the future.
11857+
priority:
11858+
allOf:
11859+
- $ref: '#/components/schemas/Priority'
11860+
description: Priority metadata
1179411861
description: |-
1179511862
Hold basic information about a workflow execution.
1179611863
This structure is a part of visibility, and thus contain a limited subset of information.
@@ -12004,6 +12071,10 @@ components:
1200412071
of starting on the Current Version of its Task Queue.
1200512072
This is set only if the child workflow is starting on a Task Queue belonging to the same
1200612073
Worker Deployment Version.
12074+
priority:
12075+
allOf:
12076+
- $ref: '#/components/schemas/Priority'
12077+
description: Priority metadata
1200712078
description: Always the first event in workflow history
1200812079
WorkflowExecutionTerminatedEventAttributes:
1200912080
type: object

temporal/api/command/v1/message.proto

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ message ScheduleActivityTaskCommandAttributes {
8585
// If this is set, the activity would be assigned to the Build ID of the workflow. Otherwise,
8686
// Assignment rules of the activity's Task Queue will be used to determine the Build ID.
8787
bool use_workflow_build_id = 13;
88+
// Priority metadata. If this message is not present, or any fields are not
89+
// present, they inherit the values from the workflow.
90+
temporal.api.common.v1.Priority priority = 14;
8891
}
8992

9093
message RequestCancelActivityTaskCommandAttributes {
@@ -226,6 +229,9 @@ message StartChildWorkflowExecutionCommandAttributes {
226229
// If this is set, the child workflow inherits the Build ID of the parent. Otherwise, the assignment
227230
// rules of the child's Task Queue will be used to independently assign a Build ID to it.
228231
bool inherit_build_id = 17;
232+
// Priority metadata. If this message is not present, or any fields are not
233+
// present, they inherit the values from the workflow.
234+
temporal.api.common.v1.Priority priority = 18;
229235
}
230236

231237
message ProtocolMessageCommandAttributes {

temporal/api/common/v1/message.proto

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,3 +247,36 @@ message Link {
247247
BatchJob batch_job = 2;
248248
}
249249
}
250+
251+
// Priority contains metadata that controls relative ordering of task processing
252+
// when tasks are backlogged in a queue. Initially, Priority will be used in
253+
// activity and workflow task queues, which are typically where backlogs exist.
254+
// Other queues in the server (such as transfer and timer queues) and rate
255+
// limiting decisions do not use Priority, but may in the future.
256+
//
257+
// Priority is attached to workflows and activities. Activities and child
258+
// workflows inherit Priority from the workflow that created them, but may
259+
// override fields when they are started or modified. For each field of a
260+
// Priority on an activity/workflow, not present or equal to zero/empty string
261+
// means to inherit the value from the calling workflow, or if there is no
262+
// calling workflow, then use the default (documented below).
263+
//
264+
// Despite being named "Priority", this message will also contains fields that
265+
// control "fairness" mechanisms.
266+
//
267+
// The overall semantics of Priority are:
268+
// 1. First, consider "priority_key": lower number goes first.
269+
// (more will be added here later)
270+
message Priority {
271+
// Priority key is a positive integer from 1 to n, where smaller integers
272+
// correspond to higher priorities (tasks run sooner). In general, tasks in
273+
// a queue should be processed in close to priority order, although small
274+
// deviations are possible.
275+
//
276+
// The maximum priority value (minimum priority) is determined by server
277+
// configuration, and defaults to 5.
278+
//
279+
// The default priority is (min+max)/2. With the default max of 5 and min of
280+
// 1, that comes out to 3.
281+
int32 priority_key = 1;
282+
}

temporal/api/history/v1/message.proto

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ message WorkflowExecutionStartedEventAttributes {
139139
// This is set only if the child workflow is starting on a Task Queue belonging to the same
140140
// Worker Deployment Version.
141141
string parent_pinned_worker_deployment_version = 34;
142+
143+
// Priority metadata
144+
temporal.api.common.v1.Priority priority = 35;
142145
}
143146

144147
message WorkflowExecutionCompletedEventAttributes {
@@ -348,6 +351,9 @@ message ActivityTaskScheduledEventAttributes {
348351
// If this is set, the activity would be assigned to the Build ID of the workflow. Otherwise,
349352
// Assignment rules of the activity's Task Queue will be used to determine the Build ID.
350353
bool use_workflow_build_id = 13;
354+
// Priority metadata. If this message is not present, or any fields are not
355+
// present, they inherit the values from the workflow.
356+
temporal.api.common.v1.Priority priority = 14;
351357
}
352358

353359
message ActivityTaskStartedEventAttributes {
@@ -655,6 +661,8 @@ message StartChildWorkflowExecutionInitiatedEventAttributes {
655661
// If this is set, the child workflow inherits the Build ID of the parent. Otherwise, the assignment
656662
// rules of the child's Task Queue will be used to independently assign a Build ID to it.
657663
bool inherit_build_id = 19;
664+
// Priority metadata
665+
temporal.api.common.v1.Priority priority = 20;
658666
}
659667

660668
message StartChildWorkflowExecutionFailedEventAttributes {

0 commit comments

Comments
 (0)