Skip to content

Commit

Permalink
add new type
Browse files Browse the repository at this point in the history
Signed-off-by: Fabian Martinez <[email protected]>
  • Loading branch information
famarting committed Oct 14, 2024
1 parent a41c592 commit be78592
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions workflow/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ type Client struct {
taskHubClient *durabletaskclient.TaskHubGrpcClient
}

type WorkflowIdReusePolicy struct {
OperationStatus []api.OrchestrationStatus
Action api.CreateOrchestrationAction
}

// WithInstanceID is an option to set an InstanceID when scheduling a new workflow.
func WithInstanceID(id string) api.NewOrchestrationOptions {
return api.WithInstanceID(api.InstanceID(id))
Expand All @@ -53,8 +58,11 @@ func WithStartTime(time time.Time) api.NewOrchestrationOptions {
return api.WithStartTime(time)
}

func WithReuseIDPolicy(policy *api.OrchestrationIdReusePolicy) api.NewOrchestrationOptions {
return api.WithOrchestrationIdReusePolicy(policy)
func WithReuseIDPolicy(policy WorkflowIdReusePolicy) api.NewOrchestrationOptions {
return api.WithOrchestrationIdReusePolicy(&api.OrchestrationIdReusePolicy{
OperationStatus: policy.OperationStatus,
Action: policy.Action,
})
}

// WithFetchPayloads is an option to return the payload from a workflow.
Expand Down
2 changes: 1 addition & 1 deletion workflow/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func TestClientMethods(t *testing.T) {
}
ctx := context.Background()
t.Run("ScheduleNewWorkflow - empty wf name", func(t *testing.T) {
id, err := testClient.ScheduleNewWorkflow(ctx, "", WithReuseIDPolicy(&api.OrchestrationIdReusePolicy{
id, err := testClient.ScheduleNewWorkflow(ctx, "", WithReuseIDPolicy(WorkflowIdReusePolicy{
OperationStatus: []api.OrchestrationStatus{api.RUNTIME_STATUS_COMPLETED},
Action: api.REUSE_ID_ACTION_IGNORE,
}))
Expand Down

0 comments on commit be78592

Please sign in to comment.