Skip to content

Commit 78619ba

Browse files
Fix default struct for workflow definition (#36)
1 parent d79289a commit 78619ba

File tree

7 files changed

+26
-54
lines changed

7 files changed

+26
-54
lines changed

integ/basic_workflow.go

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,15 @@ package integ
22

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

5-
type basicWorkflow struct{}
5+
type basicWorkflow struct {
6+
iwf.DefaultWorkflowType
7+
iwf.EmptyPersistenceSchema
8+
iwf.EmptyCommunicationSchema
9+
}
610

711
func (b basicWorkflow) GetStates() []iwf.StateDef {
812
return []iwf.StateDef{
913
iwf.StartingStateDef(&basicWorkflowState1{}),
1014
iwf.NonStartingStateDef(&basicWorkflowState2{}),
1115
}
1216
}
13-
14-
func (b basicWorkflow) GetPersistenceSchema() []iwf.PersistenceFieldDef {
15-
return nil
16-
}
17-
18-
func (b basicWorkflow) GetCommunicationSchema() []iwf.CommunicationMethodDef {
19-
return nil
20-
}
21-
22-
func (b basicWorkflow) GetWorkflowType() string {
23-
return ""
24-
}

integ/interstate_workflow.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ package integ
22

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

5-
type interStateWorkflow struct{}
5+
type interStateWorkflow struct {
6+
iwf.DefaultWorkflowType
7+
iwf.EmptyPersistenceSchema
8+
}
69

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

18-
func (b interStateWorkflow) GetPersistenceSchema() []iwf.PersistenceFieldDef {
19-
return nil
20-
}
21-
2221
func (b interStateWorkflow) GetCommunicationSchema() []iwf.CommunicationMethodDef {
2322
return []iwf.CommunicationMethodDef{
2423
iwf.InterstateChannelDef(interStateChannel1),
2524
iwf.InterstateChannelDef(interStateChannel2),
2625
}
2726
}
2827

29-
func (b interStateWorkflow) GetWorkflowType() string {
30-
return ""
31-
}

integ/persistence_workflow.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ import (
55
"github.com/indeedeng/iwf-golang-sdk/iwf"
66
)
77

8-
type persistenceWorkflow struct{}
8+
type persistenceWorkflow struct {
9+
iwf.DefaultWorkflowType
10+
iwf.EmptyCommunicationSchema
11+
}
912

1013
const (
1114
testDataObjectKey = "test-data-object"
@@ -36,11 +39,3 @@ func (b persistenceWorkflow) GetPersistenceSchema() []iwf.PersistenceFieldDef {
3639
iwf.SearchAttributeDef(testSearchAttributeKeyword, iwfidl.KEYWORD),
3740
}
3841
}
39-
40-
func (b persistenceWorkflow) GetCommunicationSchema() []iwf.CommunicationMethodDef {
41-
return nil
42-
}
43-
44-
func (b persistenceWorkflow) GetWorkflowType() string {
45-
return ""
46-
}

integ/signal_workflow.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ package integ
22

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

5-
type signalWorkflow struct{}
5+
type signalWorkflow struct {
6+
iwf.DefaultWorkflowType
7+
iwf.EmptyPersistenceSchema
8+
}
69

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

17-
func (b signalWorkflow) GetPersistenceSchema() []iwf.PersistenceFieldDef {
18-
return nil
19-
}
20-
2120
func (b signalWorkflow) GetCommunicationSchema() []iwf.CommunicationMethodDef {
2221
return []iwf.CommunicationMethodDef{
2322
iwf.SignalChannelDef(testChannelName1),
2423
iwf.SignalChannelDef(testChannelName2),
2524
}
2625
}
27-
28-
func (b signalWorkflow) GetWorkflowType() string {
29-
return ""
30-
}

integ/timer_workflow.go

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,15 @@ package integ
22

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

5-
type timerWorkflow struct{}
5+
type timerWorkflow struct {
6+
iwf.DefaultWorkflowType
7+
iwf.EmptyCommunicationSchema
8+
iwf.EmptyPersistenceSchema
9+
}
610

711
func (b timerWorkflow) GetStates() []iwf.StateDef {
812
return []iwf.StateDef{
913
iwf.StartingStateDef(&timerWorkflowState1{}),
1014
}
1115
}
1216

13-
func (b timerWorkflow) GetPersistenceSchema() []iwf.PersistenceFieldDef {
14-
return nil
15-
}
16-
17-
func (b timerWorkflow) GetCommunicationSchema() []iwf.CommunicationMethodDef {
18-
return nil
19-
}
20-
21-
func (b timerWorkflow) GetWorkflowType() string {
22-
return ""
23-
}

integ/timer_workflow_state1.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import (
66
)
77

88
type timerWorkflowState1 struct {
9-
iwf.DefaultStateIdAndOptions
9+
iwf.DefaultStateId
10+
iwf.DefaultStateOptions
1011
}
1112

1213
func (b timerWorkflowState1) Start(ctx iwf.WorkflowContext, input iwf.Object, persistence iwf.Persistence, communication iwf.Communication) (*iwf.CommandRequest, error) {

iwf/workflow.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func (d DefaultWorkflowType) GetWorkflowType() string {
105105
// }
106106
type EmptyPersistenceSchema struct{}
107107

108-
func (d DefaultWorkflowType) GetPersistenceSchema() []PersistenceFieldDef {
108+
func (d EmptyPersistenceSchema) GetPersistenceSchema() []PersistenceFieldDef {
109109
return nil
110110
}
111111

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

118-
func (d EmptyPersistenceSchema) GetCommunicationSchema() []CommunicationMethodDef {
118+
func (d EmptyCommunicationSchema) GetCommunicationSchema() []CommunicationMethodDef {
119119
return nil
120120
}

0 commit comments

Comments
 (0)