Skip to content

Commit 11ed3e5

Browse files
authored
add workflow id reuse policy to child workflow (#338)
1 parent c943d2a commit 11ed3e5

File tree

6 files changed

+122
-41
lines changed

6 files changed

+122
-41
lines changed

.gen/go/shared/idl.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.gen/go/shared/types.go

Lines changed: 111 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

idl/github.com/uber/cadence/shared.thrift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ struct StartChildWorkflowExecutionDecisionAttributes {
306306
70: optional i32 taskStartToCloseTimeoutSeconds
307307
80: optional ChildPolicy childPolicy
308308
90: optional binary control
309+
100: optional WorkflowIdReusePolicy workflowIdReusePolicy
309310
}
310311

311312
struct Decision {
@@ -538,6 +539,7 @@ struct StartChildWorkflowExecutionInitiatedEventAttributes {
538539
80: optional ChildPolicy childPolicy
539540
90: optional binary control
540541
100: optional i64 (js.type = "Long") decisionTaskCompletedEventId
542+
110: optional WorkflowIdReusePolicy workflowIdReusePolicy
541543
}
542544

543545
struct StartChildWorkflowExecutionFailedEventAttributes {

internal/internal_event_handlers.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ func (wc *workflowEnvironmentImpl) ExecuteChildWorkflow(
223223
attributes.Input = options.input
224224
attributes.WorkflowType = workflowTypePtr(*options.workflowType)
225225
attributes.ChildPolicy = options.childPolicy.toThriftChildPolicyPtr()
226+
attributes.WorkflowIdReusePolicy = options.workflowIDReusePolicy.toThriftPtr()
226227

227228
decision := wc.decisionsHelper.startChildWorkflowExecution(attributes)
228229
decision.setData(&scheduledChildWorkflow{

internal/internal_workflow.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ type (
164164
waitForCancellation bool
165165
signalChannels map[string]Channel
166166
queryHandlers map[string]func([]byte) ([]byte, error)
167+
workflowIDReusePolicy WorkflowIDReusePolicy
167168
}
168169

169170
// decodeFutureImpl

internal/workflow.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,10 @@ type (
162162
// as: completed/failed/timedout/terminated/canceled)
163163
// Optional: default false
164164
WaitForCancellation bool
165+
166+
// WorkflowIDReusePolicy - Whether server allow reuse of workflow ID, can be useful
167+
// for dedup logic if set to WorkflowIdReusePolicyRejectDuplicate
168+
WorkflowIDReusePolicy WorkflowIDReusePolicy
165169
}
166170

167171
// ChildWorkflowPolicy defines child workflow behavior when parent workflow is terminated.
@@ -495,6 +499,7 @@ func WithChildWorkflowOptions(ctx Context, cwo ChildWorkflowOptions) Context {
495499
wfOptions.taskStartToCloseTimeoutSeconds = common.Int32Ptr(int32(cwo.TaskStartToCloseTimeout.Seconds()))
496500
wfOptions.childPolicy = cwo.ChildPolicy
497501
wfOptions.waitForCancellation = cwo.WaitForCancellation
502+
wfOptions.workflowIDReusePolicy = cwo.WorkflowIDReusePolicy
498503

499504
return ctx1
500505
}

0 commit comments

Comments
 (0)