Skip to content

Commit e1a80bb

Browse files
authored
Add OnConflictOptions to StartWorkflowExecutionRequest (#510)
_**READ BEFORE MERGING:** All PRs require approval by both Server AND SDK teams before merging! This is why the number of required approvals is "2" and not "1"--two reviewers from the same team is NOT sufficient. If your PR is not approved by someone in BOTH teams, it may be summarily reverted._ <!-- Describe what has changed in this PR --> **What changed?** Add `OnConflictOptions` to `StartWorkflowExecutionRequest` <!-- Tell your future self why have you made these changes --> **Why?** When the workflow id conflict policy is `USE_EXISTING`, `OnConflictOptions` add the ability to change the existing running workflow. <!-- Are there any breaking changes on binary or code level? --> **Breaking changes** <!-- If this breaks the Server, please provide the Server PR to merge right after this PR was merged. --> **Server PR** temporalio/temporal#7080
1 parent a1edc73 commit e1a80bb

File tree

5 files changed

+96
-0
lines changed

5 files changed

+96
-0
lines changed

openapi/openapiv2.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6533,6 +6533,10 @@
65336533
"versioningOverride": {
65346534
"$ref": "#/definitions/v1VersioningOverride",
65356535
"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."
6536+
},
6537+
"onConflictOptions": {
6538+
"$ref": "#/definitions/v1OnConflictOptions",
6539+
"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."
65366540
}
65376541
}
65386542
},
@@ -9986,6 +9990,24 @@
99869990
},
99879991
"description": "Nexus operation timed out."
99889992
},
9993+
"v1OnConflictOptions": {
9994+
"type": "object",
9995+
"properties": {
9996+
"attachRequestId": {
9997+
"type": "boolean",
9998+
"description": "Attaches the request ID to the running workflow."
9999+
},
10000+
"attachCompletionCallbacks": {
10001+
"type": "boolean",
10002+
"description": "Attaches the completion callbacks to the running workflow."
10003+
},
10004+
"attachLinks": {
10005+
"type": "boolean",
10006+
"description": "Attaches the links to the WorkflowExecutionOptionsUpdatedEvent history event."
10007+
}
10008+
},
10009+
"description": "When StartWorkflowExecution uses the conflict policy WORKFLOW_ID_CONFLICT_POLICY_USE_EXISTING and\nthere is already an existing running workflow, OnConflictOptions defines actions to be taken on\nthe existing running workflow. In this case, it will create a WorkflowExecutionOptionsUpdatedEvent\nhistory event in the running workflow with the changes requested in this object."
10010+
},
998910011
"v1Outcome": {
999010012
"type": "object",
999110013
"properties": {
@@ -12019,6 +12041,10 @@
1201912041
"versioningOverride": {
1202012042
"$ref": "#/definitions/v1VersioningOverride",
1202112043
"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."
12044+
},
12045+
"onConflictOptions": {
12046+
"$ref": "#/definitions/v1OnConflictOptions",
12047+
"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."
1202212048
}
1202312049
}
1202412050
},
@@ -13093,6 +13119,18 @@
1309313119
"unsetVersioningOverride": {
1309413120
"type": "boolean",
1309513121
"description": "Versioning override removed in this event."
13122+
},
13123+
"attachedRequestId": {
13124+
"type": "string",
13125+
"description": "Request ID attachedto the running workflow execution so that subsequent requests with same\nrequest ID will be deduped."
13126+
},
13127+
"attachedCompletionCallbacks": {
13128+
"type": "array",
13129+
"items": {
13130+
"type": "object",
13131+
"$ref": "#/definitions/v1Callback"
13132+
},
13133+
"description": "Completion callbacks attached to the running workflow execution."
1309613134
}
1309713135
}
1309813136
},

openapi/openapiv3.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7474,6 +7474,23 @@ components:
74747474
type: string
74757475
description: The request ID allocated at schedule time.
74767476
description: Nexus operation timed out.
7477+
OnConflictOptions:
7478+
type: object
7479+
properties:
7480+
attachRequestId:
7481+
type: boolean
7482+
description: Attaches the request ID to the running workflow.
7483+
attachCompletionCallbacks:
7484+
type: boolean
7485+
description: Attaches the completion callbacks to the running workflow.
7486+
attachLinks:
7487+
type: boolean
7488+
description: Attaches the links to the WorkflowExecutionOptionsUpdatedEvent history event.
7489+
description: |-
7490+
When StartWorkflowExecution uses the conflict policy WORKFLOW_ID_CONFLICT_POLICY_USE_EXISTING and
7491+
there is already an existing running workflow, OnConflictOptions defines actions to be taken on
7492+
the existing running workflow. In this case, it will create a WorkflowExecutionOptionsUpdatedEvent
7493+
history event in the running workflow with the changes requested in this object.
74777494
Outcome:
74787495
type: object
74797496
properties:
@@ -9411,6 +9428,14 @@ components:
94119428
description: |-
94129429
If set, takes precedence over the Versioning Behavior sent by the SDK on Workflow Task completion.
94139430
To unset the override after the workflow is running, use UpdateWorkflowExecutionOptions.
9431+
onConflictOptions:
9432+
allOf:
9433+
- $ref: '#/components/schemas/OnConflictOptions'
9434+
description: |-
9435+
Defines actions to be done to the existing running workflow when the conflict policy
9436+
WORKFLOW_ID_CONFLICT_POLICY_USE_EXISTING is used. If not set (ie., nil value) or set to a
9437+
empty object (ie., all options with default value), it won't do anything to the existing
9438+
running workflow. If set, it will add a history event to the running workflow.
94149439
StartWorkflowExecutionResponse:
94159440
type: object
94169441
properties:
@@ -10591,6 +10616,16 @@ components:
1059110616
unsetVersioningOverride:
1059210617
type: boolean
1059310618
description: Versioning override removed in this event.
10619+
attachedRequestId:
10620+
type: string
10621+
description: |-
10622+
Request ID attachedto the running workflow execution so that subsequent requests with same
10623+
request ID will be deduped.
10624+
attachedCompletionCallbacks:
10625+
type: array
10626+
items:
10627+
$ref: '#/components/schemas/Callback'
10628+
description: Completion callbacks attached to the running workflow execution.
1059410629
WorkflowExecutionSignaledEventAttributes:
1059510630
type: object
1059610631
properties:

temporal/api/history/v1/message.proto

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,11 @@ message WorkflowExecutionOptionsUpdatedEventAttributes {
746746
temporal.api.workflow.v1.VersioningOverride versioning_override = 1;
747747
// Versioning override removed in this event.
748748
bool unset_versioning_override = 2;
749+
// Request ID attachedto the running workflow execution so that subsequent requests with same
750+
// request ID will be deduped.
751+
string attached_request_id = 3;
752+
// Completion callbacks attached to the running workflow execution.
753+
repeated temporal.api.common.v1.Callback attached_completion_callbacks = 4;
749754
}
750755

751756
// Not used anywhere. Use case is replaced by WorkflowExecutionOptionsUpdatedEventAttributes

temporal/api/workflow/v1/message.proto

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,3 +440,16 @@ message VersioningOverride {
440440
// Identifies the worker deployment to pin the workflow to.
441441
temporal.api.deployment.v1.Deployment deployment = 2;
442442
}
443+
444+
// When StartWorkflowExecution uses the conflict policy WORKFLOW_ID_CONFLICT_POLICY_USE_EXISTING and
445+
// there is already an existing running workflow, OnConflictOptions defines actions to be taken on
446+
// the existing running workflow. In this case, it will create a WorkflowExecutionOptionsUpdatedEvent
447+
// history event in the running workflow with the changes requested in this object.
448+
message OnConflictOptions {
449+
// Attaches the request ID to the running workflow.
450+
bool attach_request_id = 1;
451+
// Attaches the completion callbacks to the running workflow.
452+
bool attach_completion_callbacks = 2;
453+
// Attaches the links to the WorkflowExecutionOptionsUpdatedEvent history event.
454+
bool attach_links = 3;
455+
}

temporal/api/workflowservice/v1/request_response.proto

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,11 @@ message StartWorkflowExecutionRequest {
206206
// If set, takes precedence over the Versioning Behavior sent by the SDK on Workflow Task completion.
207207
// To unset the override after the workflow is running, use UpdateWorkflowExecutionOptions.
208208
temporal.api.workflow.v1.VersioningOverride versioning_override = 25;
209+
// Defines actions to be done to the existing running workflow when the conflict policy
210+
// WORKFLOW_ID_CONFLICT_POLICY_USE_EXISTING is used. If not set (ie., nil value) or set to a
211+
// empty object (ie., all options with default value), it won't do anything to the existing
212+
// running workflow. If set, it will add a history event to the running workflow.
213+
temporal.api.workflow.v1.OnConflictOptions on_conflict_options = 26;
209214
}
210215

211216
message StartWorkflowExecutionResponse {

0 commit comments

Comments
 (0)