Skip to content

Commit

Permalink
add workflow id reuse policy to child workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Wenquan Xing committed Jan 9, 2018
1 parent 6e69f89 commit c1f85e4
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 41 deletions.
4 changes: 2 additions & 2 deletions .gen/go/shared/idl.go

Large diffs are not rendered by default.

150 changes: 111 additions & 39 deletions .gen/go/shared/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions idl/github.com/uber/cadence/shared.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ struct StartChildWorkflowExecutionDecisionAttributes {
70: optional i32 taskStartToCloseTimeoutSeconds
80: optional ChildPolicy childPolicy
90: optional binary control
100: optional WorkflowIdReusePolicy workflowIdReusePolicy
}

struct Decision {
Expand Down Expand Up @@ -538,6 +539,7 @@ struct StartChildWorkflowExecutionInitiatedEventAttributes {
80: optional ChildPolicy childPolicy
90: optional binary control
100: optional i64 (js.type = "Long") decisionTaskCompletedEventId
110: optional WorkflowIdReusePolicy workflowIdReusePolicy
}

struct StartChildWorkflowExecutionFailedEventAttributes {
Expand Down
1 change: 1 addition & 0 deletions internal/internal_event_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ func (wc *workflowEnvironmentImpl) ExecuteChildWorkflow(
attributes.Input = options.input
attributes.WorkflowType = workflowTypePtr(*options.workflowType)
attributes.ChildPolicy = options.childPolicy.toThriftChildPolicyPtr()
attributes.WorkflowIdReusePolicy = options.workflowIDReusePolicy.toThriftPtr()

decision := wc.decisionsHelper.startChildWorkflowExecution(attributes)
decision.setData(&scheduledChildWorkflow{
Expand Down
1 change: 1 addition & 0 deletions internal/internal_workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ type (
waitForCancellation bool
signalChannels map[string]Channel
queryHandlers map[string]func([]byte) ([]byte, error)
workflowIDReusePolicy WorkflowIDReusePolicy
}

// decodeFutureImpl
Expand Down
5 changes: 5 additions & 0 deletions internal/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ type (
// as: completed/failed/timedout/terminated/canceled)
// Optional: default false
WaitForCancellation bool

// WorkflowIDReusePolicy - Whether server allow reuse of workflow ID, can be useful
// for dedup logic if set to WorkflowIdReusePolicyRejectDuplicate
WorkflowIDReusePolicy WorkflowIDReusePolicy
}

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

return ctx1
}
Expand Down

0 comments on commit c1f85e4

Please sign in to comment.