Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion event_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ func ExampleNewEventBuilder() {

// Output: unmonitored
// stopped
// no matching transition
// no transition from state=stopped for event=monitor: no matching transition
}
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module github.com/Gurpartap/statemachine-go

go 1.13
go 1.20

require github.com/hashicorp/hcl v1.0.0
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
16 changes: 8 additions & 8 deletions machine_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func (m *machineImpl) Fire(event string) (err error) {
var transition Transition
transition, err = m.findTransition(event, fromState)
if err != nil {
return
return fmt.Errorf("no transition from state=%s for event=%s: %w", fromState, event, err)
}

err = m.applyTransition(transition)
Expand Down Expand Up @@ -396,13 +396,13 @@ func (m *machineImpl) applyTransition(transition Transition) error {
return nil
}

// callback1(next: {
// callback2(next: {
// callback3(next: {
// applyTransition()
// })
// })
// })
// callback1(next: {
// callback2(next: {
// callback3(next: {
// applyTransition()
// })
// })
// })
func (m *machineImpl) applyTransitionAroundCallbacks(callbacks []*TransitionCallbackFuncDef, args map[reflect.Type]interface{}, applyTransition func()) {
if len(callbacks) == 0 {
applyTransition()
Expand Down