Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add id-conflict-policy #688

Merged
merged 2 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions temporalcli/commands.gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,11 @@ func (v *SharedWorkflowStartOptions) buildFlags(cctx *CommandContext, f *pflag.F
}

type WorkflowStartOptions struct {
Cron string
FailExisting bool
StartDelay Duration
IdReusePolicy StringEnum
Cron string
FailExisting bool
StartDelay Duration
IdReusePolicy StringEnum
IdConflictPolicy StringEnum
}

func (v *WorkflowStartOptions) buildFlags(cctx *CommandContext, f *pflag.FlagSet) {
Expand All @@ -190,6 +191,8 @@ func (v *WorkflowStartOptions) buildFlags(cctx *CommandContext, f *pflag.FlagSet
f.Var(&v.StartDelay, "start-delay", "Delay before starting the Workflow Execution. Can't be used with cron schedules. If the Workflow receives a signal or update prior to this time, the Workflow Execution starts immediately.")
v.IdReusePolicy = NewStringEnum([]string{"AllowDuplicate", "AllowDuplicateFailedOnly", "RejectDuplicate", "TerminateIfRunning"}, "")
f.Var(&v.IdReusePolicy, "id-reuse-policy", "Re-use policy for the Workflow ID in new Workflow Executions. Accepted values: AllowDuplicate, AllowDuplicateFailedOnly, RejectDuplicate, TerminateIfRunning.")
v.IdConflictPolicy = NewStringEnum([]string{"Fail", "UseExisting", "TerminateExisting"}, "")
f.Var(&v.IdConflictPolicy, "id-conflict-policy", "Determines how to resolve a conflict when spawning a new Workflow Execution with a particular Workflow Id used by an existing Open Workflow Execution. Accepted values: Fail, UseExisting, TerminateExisting.")
}

type PayloadInputOptions struct {
Expand Down
8 changes: 8 additions & 0 deletions temporalcli/commands.workflow_exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,14 @@ func buildStartOptions(sw *SharedWorkflowStartOptions, w *WorkflowStartOptions)
return o, fmt.Errorf("invalid workflow ID reuse policy: %w", err)
}
}
if w.IdConflictPolicy.Value != "" {
var err error
o.WorkflowIDConflictPolicy, err = stringToProtoEnum[enums.WorkflowIdConflictPolicy](
w.IdConflictPolicy.Value, enums.WorkflowIdConflictPolicy_shorthandValue, enums.WorkflowIdConflictPolicy_value)
if err != nil {
return o, fmt.Errorf("invalid workflow ID conflict policy: %w", err)
}
}
if len(sw.Memo) > 0 {
var err error
if o.Memo, err = stringKeysJSONValues(sw.Memo, false); err != nil {
Expand Down
9 changes: 9 additions & 0 deletions temporalcli/commandsgen/commands.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3228,6 +3228,15 @@ option-sets:
- AllowDuplicateFailedOnly
- RejectDuplicate
- TerminateIfRunning
- name: id-conflict-policy
type: string-enum
description: |
Determines how to resolve a conflict when spawning a new Workflow Execution
with a particular Workflow Id used by an existing Open Workflow Execution.
enum-values:
- Fail
- UseExisting
- TerminateExisting
- name: payload-input
options:
- name: input
Expand Down
Loading