Skip to content

Commit

Permalink
workflows support reuse id policy
Browse files Browse the repository at this point in the history
Signed-off-by: Fabian Martinez <[email protected]>
  • Loading branch information
famarting committed Oct 11, 2024
1 parent 9bc7d82 commit a41c592
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions workflow/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ func WithStartTime(time time.Time) api.NewOrchestrationOptions {
return api.WithStartTime(time)
}

func WithReuseIDPolicy(policy *api.OrchestrationIdReusePolicy) api.NewOrchestrationOptions {
return api.WithOrchestrationIdReusePolicy(policy)
}

// WithFetchPayloads is an option to return the payload from a workflow.
func WithFetchPayloads(fetchPayloads bool) api.FetchOrchestrationMetadataOptions {
return api.WithFetchPayloads(fetchPayloads)
Expand Down
6 changes: 5 additions & 1 deletion workflow/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"context"
"testing"

"github.com/microsoft/durabletask-go/api"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

Expand Down Expand Up @@ -54,7 +55,10 @@ func TestClientMethods(t *testing.T) {
}
ctx := context.Background()
t.Run("ScheduleNewWorkflow - empty wf name", func(t *testing.T) {
id, err := testClient.ScheduleNewWorkflow(ctx, "", nil)
id, err := testClient.ScheduleNewWorkflow(ctx, "", WithReuseIDPolicy(&api.OrchestrationIdReusePolicy{
OperationStatus: []api.OrchestrationStatus{api.RUNTIME_STATUS_COMPLETED},
Action: api.REUSE_ID_ACTION_IGNORE,
}))
require.Error(t, err)
assert.Empty(t, id)
})
Expand Down

0 comments on commit a41c592

Please sign in to comment.