Skip to content

Commit

Permalink
wrap all types
Browse files Browse the repository at this point in the history
  • Loading branch information
famarting committed Oct 21, 2024
1 parent da81209 commit 52b281d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
25 changes: 23 additions & 2 deletions workflow/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
5 changes: 2 additions & 3 deletions workflow/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"context"
"testing"

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

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 52b281d

Please sign in to comment.