-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
37af5d4
commit 877c7ea
Showing
22 changed files
with
134 additions
and
386 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,18 @@ | ||
package interstate | ||
|
||
import ( | ||
"github.com/indeedeng/iwf-golang-sdk/gen/iwfidl" | ||
"github.com/indeedeng/iwf-golang-sdk/iwf" | ||
) | ||
|
||
type interStateWorkflowState2 struct{} | ||
|
||
const interStateWorkflowState2Id = "interStateWorkflowState2" | ||
|
||
func (b interStateWorkflowState2) GetStateId() string { | ||
return interStateWorkflowState2Id | ||
type interStateWorkflowState2 struct { | ||
iwf.DefaultStateIdAndOptions | ||
} | ||
|
||
func (b interStateWorkflowState2) Start(ctx iwf.WorkflowContext, input iwf.Object, persistence iwf.Persistence, communication iwf.Communication) (*iwf.CommandRequest, error) { | ||
err := communication.PublishInterstateChannel(interStateChannel2, 2) | ||
if err != nil { | ||
return nil, err | ||
} | ||
communication.PublishInterstateChannel(interStateChannel2, 2) | ||
return iwf.EmptyCommandRequest(), nil | ||
} | ||
|
||
func (b interStateWorkflowState2) Decide(ctx iwf.WorkflowContext, input iwf.Object, commandResults iwf.CommandResults, persistence iwf.Persistence, communication iwf.Communication) (*iwf.StateDecision, error) { | ||
return iwf.DeadEnd, nil | ||
} | ||
|
||
func (b interStateWorkflowState2) GetStateOptions() *iwfidl.WorkflowStateOptions { | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,39 @@ | ||
package persistence | ||
|
||
import ( | ||
"github.com/indeedeng/iwf-golang-sdk/gen/iwfidl" | ||
"github.com/indeedeng/iwf-golang-sdk/iwf" | ||
) | ||
|
||
type persistenceWorkflowState1 struct{} | ||
|
||
const PersistenceWorkflowState1Id = "persistenceWorkflowState1" | ||
|
||
func (b persistenceWorkflowState1) GetStateId() string { | ||
return PersistenceWorkflowState1Id | ||
type persistenceWorkflowState1 struct { | ||
iwf.DefaultStateIdAndOptions | ||
} | ||
|
||
func (b persistenceWorkflowState1) Start(ctx iwf.WorkflowContext, input iwf.Object, persistence iwf.Persistence, communication iwf.Communication) (*iwf.CommandRequest, error) { | ||
var do ExampleDataObjectModel | ||
err := persistence.GetDataObject(testDataObjectKey, &do) | ||
if err != nil { | ||
return nil, err | ||
} | ||
persistence.GetDataObject(testDataObjectKey, &do) | ||
if do.StrValue == "" && do.IntValue == 0 { | ||
err := input.Get(&do) | ||
if err != nil { | ||
return nil, err | ||
} | ||
input.Get(&do) | ||
if do.StrValue == "" || do.IntValue == 0 { | ||
panic("this value shouldn't be empty as we got it from start request") | ||
} | ||
} else { | ||
panic("this value should be empty because we haven't set it before") | ||
} | ||
err = persistence.SetDataObject(testDataObjectKey, do) | ||
if err != nil { | ||
return nil, err | ||
} | ||
err = persistence.SetSearchAttributeInt(testSearchAttributeInt, 1) | ||
if err != nil { | ||
return nil, err | ||
} | ||
persistence.SetDataObject(testDataObjectKey, do) | ||
persistence.SetSearchAttributeInt(testSearchAttributeInt, 1) | ||
|
||
return iwf.EmptyCommandRequest(), nil | ||
} | ||
|
||
func (b persistenceWorkflowState1) Decide(ctx iwf.WorkflowContext, input iwf.Object, commandResults iwf.CommandResults, persistence iwf.Persistence, communication iwf.Communication) (*iwf.StateDecision, error) { | ||
iv, err := persistence.GetSearchAttributeInt(testSearchAttributeInt) | ||
if err != nil { | ||
return nil, err | ||
} | ||
iv := persistence.GetSearchAttributeInt(testSearchAttributeInt) | ||
if iv != 1 { | ||
panic("this value must be 1 because it got set by Start API") | ||
} | ||
|
||
var do ExampleDataObjectModel | ||
err = persistence.GetDataObject(testDataObjectKey, &do) | ||
if err != nil { | ||
return nil, err | ||
} | ||
err = persistence.SetSearchAttributeDatetime(testSearchAttributeDatetime, do.Datetime) | ||
if err != nil { | ||
return nil, err | ||
} | ||
err = persistence.SetSearchAttributeBool(testSearchAttributeBool, true) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return iwf.SingleNextState(persistenceWorkflowState2Id, nil), nil | ||
} | ||
|
||
func (b persistenceWorkflowState1) GetStateOptions() *iwfidl.WorkflowStateOptions { | ||
return nil | ||
persistence.GetDataObject(testDataObjectKey, &do) | ||
persistence.SetSearchAttributeDatetime(testSearchAttributeDatetime, do.Datetime) | ||
persistence.SetSearchAttributeBool(testSearchAttributeBool, true) | ||
return iwf.SingleNextState(persistenceWorkflowState2{}, nil), nil | ||
} |
Oops, something went wrong.