From 52b281d03184457961d9a56458ae0f3ad7f0de00 Mon Sep 17 00:00:00 2001 From: Fabian Martinez <46371672+famarting@users.noreply.github.com> Date: Mon, 21 Oct 2024 16:32:50 +0200 Subject: [PATCH] wrap all types --- workflow/client.go | 25 +++++++++++++++++++++++-- workflow/client_test.go | 5 ++--- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/workflow/client.go b/workflow/client.go index 5e443774..4f44cbd5 100644 --- a/workflow/client.go +++ b/workflow/client.go @@ -32,10 +32,31 @@ type Client struct { } type WorkflowIDReusePolicy struct { - OperationStatus []api.OrchestrationStatus - Action api.CreateOrchestrationAction + OperationStatus []WorkflowOperationStatus + Action CreateWorkflowAction } +type WorkflowOperationStatus = api.OrchestrationStatus + +const ( + RUNTIME_STATUS_RUNNING WorkflowOperationStatus = api.RUNTIME_STATUS_RUNNING + RUNTIME_STATUS_COMPLETED WorkflowOperationStatus = api.RUNTIME_STATUS_COMPLETED + RUNTIME_STATUS_CONTINUED_AS_NEW WorkflowOperationStatus = api.RUNTIME_STATUS_CONTINUED_AS_NEW + RUNTIME_STATUS_FAILED WorkflowOperationStatus = api.RUNTIME_STATUS_FAILED + RUNTIME_STATUS_CANCELED WorkflowOperationStatus = api.RUNTIME_STATUS_CANCELED + RUNTIME_STATUS_TERMINATED WorkflowOperationStatus = api.RUNTIME_STATUS_TERMINATED + RUNTIME_STATUS_PENDING WorkflowOperationStatus = api.RUNTIME_STATUS_PENDING + RUNTIME_STATUS_SUSPENDED WorkflowOperationStatus = api.RUNTIME_STATUS_SUSPENDED +) + +type CreateWorkflowAction = api.CreateOrchestrationAction + +const ( + REUSE_ID_ACTION_ERROR CreateWorkflowAction = api.REUSE_ID_ACTION_ERROR + REUSE_ID_ACTION_IGNORE CreateWorkflowAction = api.REUSE_ID_ACTION_IGNORE + REUSE_ID_ACTION_TERMINATE CreateWorkflowAction = api.REUSE_ID_ACTION_TERMINATE +) + // 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)) diff --git a/workflow/client_test.go b/workflow/client_test.go index 16b705aa..493b533c 100644 --- a/workflow/client_test.go +++ b/workflow/client_test.go @@ -18,7 +18,6 @@ import ( "context" "testing" - "github.com/microsoft/durabletask-go/api" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -56,8 +55,8 @@ func TestClientMethods(t *testing.T) { ctx := context.Background() t.Run("ScheduleNewWorkflow - empty wf name", func(t *testing.T) { id, err := testClient.ScheduleNewWorkflow(ctx, "", WithReuseIDPolicy(WorkflowIDReusePolicy{ - OperationStatus: []api.OrchestrationStatus{api.RUNTIME_STATUS_COMPLETED}, - Action: api.REUSE_ID_ACTION_IGNORE, + OperationStatus: []WorkflowOperationStatus{RUNTIME_STATUS_COMPLETED}, + Action: REUSE_ID_ACTION_IGNORE, })) require.Error(t, err) assert.Empty(t, id)