Skip to content

Commit 9109a85

Browse files
authored
add on conflict options for standalone activities (#764)
**What changed?** Added a new OnConflictOptions message to temporal.api.activity.v1 and a corresponding on_conflict_options field to StartActivityExecutionRequest. **Why?** When StartActivityExecution uses ACTIVITY_ID_CONFLICT_POLICY_USE_EXISTING and a matching activity is already running, the caller needs a way to specify what should be attached to the existing activity (request ID, completion callbacks, links). This mirrors the existing OnConflictOptions for workflows (temporal.api.workflow.v1.OnConflictOptions on StartWorkflowExecutionRequest) but is specific to the activity domain.
1 parent ddc38c8 commit 9109a85

4 files changed

Lines changed: 63 additions & 26 deletions

File tree

openapi/openapiv2.json

Lines changed: 41 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10466,6 +10466,10 @@
1046610466
"$ref": "#/definitions/apiCommonV1Link"
1046710467
},
1046810468
"description": "Links to be associated with the activity. Callbacks may also have associated links;\nlinks already included with a callback should not be duplicated here."
10469+
},
10470+
"onConflictOptions": {
10471+
"$ref": "#/definitions/apiCommonV1OnConflictOptions",
10472+
"description": "Options for handling conflicts when using ACTIVITY_ID_CONFLICT_POLICY_USE_EXISTING."
1046910473
}
1047010474
}
1047110475
},
@@ -10620,7 +10624,7 @@
1062010624
"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."
1062110625
},
1062210626
"onConflictOptions": {
10623-
"$ref": "#/definitions/v1OnConflictOptions",
10627+
"$ref": "#/definitions/apiWorkflowV1OnConflictOptions",
1062410628
"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."
1062510629
},
1062610630
"priority": {
@@ -11177,6 +11181,24 @@
1117711181
},
1117811182
"description": "Common callback information. Specific CallbackInfo messages should embed this and may include additional fields."
1117911183
},
11184+
"apiCommonV1OnConflictOptions": {
11185+
"type": "object",
11186+
"properties": {
11187+
"attachRequestId": {
11188+
"type": "boolean",
11189+
"description": "Attaches the request ID to the running execution."
11190+
},
11191+
"attachCompletionCallbacks": {
11192+
"type": "boolean",
11193+
"description": "Attaches the completion callbacks to the running execution."
11194+
},
11195+
"attachLinks": {
11196+
"type": "boolean",
11197+
"description": "Attaches the links to the running execution."
11198+
}
11199+
},
11200+
"description": "When starting an execution with a conflict policy that uses an existing execution and there is already an existing\nrunning execution, OnConflictOptions defines actions to be taken on the existing running execution."
11201+
},
1118011202
"apiWorkflowV1CallbackInfo": {
1118111203
"type": "object",
1118211204
"properties": {
@@ -11230,6 +11252,24 @@
1123011252
}
1123111253
}
1123211254
},
11255+
"apiWorkflowV1OnConflictOptions": {
11256+
"type": "object",
11257+
"properties": {
11258+
"attachRequestId": {
11259+
"type": "boolean",
11260+
"description": "Attaches the request ID to the running workflow."
11261+
},
11262+
"attachCompletionCallbacks": {
11263+
"type": "boolean",
11264+
"description": "Attaches the completion callbacks to the running workflow."
11265+
},
11266+
"attachLinks": {
11267+
"type": "boolean",
11268+
"description": "Attaches the links to the WorkflowExecutionOptionsUpdatedEvent history event."
11269+
}
11270+
},
11271+
"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."
11272+
},
1123311273
"protobufAny": {
1123411274
"type": "object",
1123511275
"properties": {
@@ -14926,24 +14966,6 @@
1492614966
},
1492714967
"description": "Nexus operation timed out."
1492814968
},
14929-
"v1OnConflictOptions": {
14930-
"type": "object",
14931-
"properties": {
14932-
"attachRequestId": {
14933-
"type": "boolean",
14934-
"description": "Attaches the request ID to the running workflow."
14935-
},
14936-
"attachCompletionCallbacks": {
14937-
"type": "boolean",
14938-
"description": "Attaches the completion callbacks to the running workflow."
14939-
},
14940-
"attachLinks": {
14941-
"type": "boolean",
14942-
"description": "Attaches the links to the WorkflowExecutionOptionsUpdatedEvent history event."
14943-
}
14944-
},
14945-
"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."
14946-
},
1494714969
"v1Outcome": {
1494814970
"type": "object",
1494914971
"properties": {

openapi/openapiv3.yaml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11726,18 +11726,16 @@ components:
1172611726
properties:
1172711727
attachRequestId:
1172811728
type: boolean
11729-
description: Attaches the request ID to the running workflow.
11729+
description: Attaches the request ID to the running execution.
1173011730
attachCompletionCallbacks:
1173111731
type: boolean
11732-
description: Attaches the completion callbacks to the running workflow.
11732+
description: Attaches the completion callbacks to the running execution.
1173311733
attachLinks:
1173411734
type: boolean
11735-
description: Attaches the links to the WorkflowExecutionOptionsUpdatedEvent history event.
11735+
description: Attaches the links to the running execution.
1173611736
description: |-
11737-
When StartWorkflowExecution uses the conflict policy WORKFLOW_ID_CONFLICT_POLICY_USE_EXISTING and
11738-
there is already an existing running workflow, OnConflictOptions defines actions to be taken on
11739-
the existing running workflow. In this case, it will create a WorkflowExecutionOptionsUpdatedEvent
11740-
history event in the running workflow with the changes requested in this object.
11737+
When starting an execution with a conflict policy that uses an existing execution and there is already an existing
11738+
running execution, OnConflictOptions defines actions to be taken on the existing running execution.
1174111739
Outcome:
1174211740
type: object
1174311741
properties:
@@ -14339,6 +14337,10 @@ components:
1433914337
description: |-
1434014338
Links to be associated with the activity. Callbacks may also have associated links;
1434114339
links already included with a callback should not be duplicated here.
14340+
onConflictOptions:
14341+
allOf:
14342+
- $ref: '#/components/schemas/OnConflictOptions'
14343+
description: Options for handling conflicts when using ACTIVITY_ID_CONFLICT_POLICY_USE_EXISTING.
1434214344
StartActivityExecutionResponse:
1434314345
type: object
1434414346
properties:

temporal/api/common/v1/message.proto

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,3 +363,14 @@ message WorkerSelector {
363363
string worker_instance_key = 1;
364364
}
365365
}
366+
367+
// When starting an execution with a conflict policy that uses an existing execution and there is already an existing
368+
// running execution, OnConflictOptions defines actions to be taken on the existing running execution.
369+
message OnConflictOptions {
370+
// Attaches the request ID to the running execution.
371+
bool attach_request_id = 1;
372+
// Attaches the completion callbacks to the running execution.
373+
bool attach_completion_callbacks = 2;
374+
// Attaches the links to the running execution.
375+
bool attach_links = 3;
376+
}

temporal/api/workflowservice/v1/request_response.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2945,6 +2945,8 @@ message StartActivityExecutionRequest {
29452945
// Links to be associated with the activity. Callbacks may also have associated links;
29462946
// links already included with a callback should not be duplicated here.
29472947
repeated temporal.api.common.v1.Link links = 20;
2948+
// Options for handling conflicts when using ACTIVITY_ID_CONFLICT_POLICY_USE_EXISTING.
2949+
temporal.api.common.v1.OnConflictOptions on_conflict_options = 21;
29482950
}
29492951

29502952
message StartActivityExecutionResponse {

0 commit comments

Comments
 (0)