Skip to content

Commit

Permalink
Fix default struct for workflow definition (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
longquanzheng authored Jan 24, 2023
1 parent d79289a commit 78619ba
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 54 deletions.
18 changes: 5 additions & 13 deletions integ/basic_workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,15 @@ package integ

import "github.com/indeedeng/iwf-golang-sdk/iwf"

type basicWorkflow struct{}
type basicWorkflow struct {
iwf.DefaultWorkflowType
iwf.EmptyPersistenceSchema
iwf.EmptyCommunicationSchema
}

func (b basicWorkflow) GetStates() []iwf.StateDef {
return []iwf.StateDef{
iwf.StartingStateDef(&basicWorkflowState1{}),
iwf.NonStartingStateDef(&basicWorkflowState2{}),
}
}

func (b basicWorkflow) GetPersistenceSchema() []iwf.PersistenceFieldDef {
return nil
}

func (b basicWorkflow) GetCommunicationSchema() []iwf.CommunicationMethodDef {
return nil
}

func (b basicWorkflow) GetWorkflowType() string {
return ""
}
12 changes: 4 additions & 8 deletions integ/interstate_workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ package integ

import "github.com/indeedeng/iwf-golang-sdk/iwf"

type interStateWorkflow struct{}
type interStateWorkflow struct {
iwf.DefaultWorkflowType
iwf.EmptyPersistenceSchema
}

const interStateChannel1 = "test-inter-state-channel-1"
const interStateChannel2 = "test-inter-state-channel-2"
Expand All @@ -15,17 +18,10 @@ func (b interStateWorkflow) GetStates() []iwf.StateDef {
}
}

func (b interStateWorkflow) GetPersistenceSchema() []iwf.PersistenceFieldDef {
return nil
}

func (b interStateWorkflow) GetCommunicationSchema() []iwf.CommunicationMethodDef {
return []iwf.CommunicationMethodDef{
iwf.InterstateChannelDef(interStateChannel1),
iwf.InterstateChannelDef(interStateChannel2),
}
}

func (b interStateWorkflow) GetWorkflowType() string {
return ""
}
13 changes: 4 additions & 9 deletions integ/persistence_workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import (
"github.com/indeedeng/iwf-golang-sdk/iwf"
)

type persistenceWorkflow struct{}
type persistenceWorkflow struct {
iwf.DefaultWorkflowType
iwf.EmptyCommunicationSchema
}

const (
testDataObjectKey = "test-data-object"
Expand Down Expand Up @@ -36,11 +39,3 @@ func (b persistenceWorkflow) GetPersistenceSchema() []iwf.PersistenceFieldDef {
iwf.SearchAttributeDef(testSearchAttributeKeyword, iwfidl.KEYWORD),
}
}

func (b persistenceWorkflow) GetCommunicationSchema() []iwf.CommunicationMethodDef {
return nil
}

func (b persistenceWorkflow) GetWorkflowType() string {
return ""
}
13 changes: 4 additions & 9 deletions integ/signal_workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ package integ

import "github.com/indeedeng/iwf-golang-sdk/iwf"

type signalWorkflow struct{}
type signalWorkflow struct {
iwf.DefaultWorkflowType
iwf.EmptyPersistenceSchema
}

const testChannelName1 = "test-channel-name-1"
const testChannelName2 = "test-channel-name-2"
Expand All @@ -14,17 +17,9 @@ func (b signalWorkflow) GetStates() []iwf.StateDef {
}
}

func (b signalWorkflow) GetPersistenceSchema() []iwf.PersistenceFieldDef {
return nil
}

func (b signalWorkflow) GetCommunicationSchema() []iwf.CommunicationMethodDef {
return []iwf.CommunicationMethodDef{
iwf.SignalChannelDef(testChannelName1),
iwf.SignalChannelDef(testChannelName2),
}
}

func (b signalWorkflow) GetWorkflowType() string {
return ""
}
17 changes: 5 additions & 12 deletions integ/timer_workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,15 @@ package integ

import "github.com/indeedeng/iwf-golang-sdk/iwf"

type timerWorkflow struct{}
type timerWorkflow struct {
iwf.DefaultWorkflowType
iwf.EmptyCommunicationSchema
iwf.EmptyPersistenceSchema
}

func (b timerWorkflow) GetStates() []iwf.StateDef {
return []iwf.StateDef{
iwf.StartingStateDef(&timerWorkflowState1{}),
}
}

func (b timerWorkflow) GetPersistenceSchema() []iwf.PersistenceFieldDef {
return nil
}

func (b timerWorkflow) GetCommunicationSchema() []iwf.CommunicationMethodDef {
return nil
}

func (b timerWorkflow) GetWorkflowType() string {
return ""
}
3 changes: 2 additions & 1 deletion integ/timer_workflow_state1.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import (
)

type timerWorkflowState1 struct {
iwf.DefaultStateIdAndOptions
iwf.DefaultStateId
iwf.DefaultStateOptions
}

func (b timerWorkflowState1) Start(ctx iwf.WorkflowContext, input iwf.Object, persistence iwf.Persistence, communication iwf.Communication) (*iwf.CommandRequest, error) {
Expand Down
4 changes: 2 additions & 2 deletions iwf/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func (d DefaultWorkflowType) GetWorkflowType() string {
// }
type EmptyPersistenceSchema struct{}

func (d DefaultWorkflowType) GetPersistenceSchema() []PersistenceFieldDef {
func (d EmptyPersistenceSchema) GetPersistenceSchema() []PersistenceFieldDef {
return nil
}

Expand All @@ -115,6 +115,6 @@ func (d DefaultWorkflowType) GetPersistenceSchema() []PersistenceFieldDef {
// }
type EmptyCommunicationSchema struct{}

func (d EmptyPersistenceSchema) GetCommunicationSchema() []CommunicationMethodDef {
func (d EmptyCommunicationSchema) GetCommunicationSchema() []CommunicationMethodDef {
return nil
}

0 comments on commit 78619ba

Please sign in to comment.