I am writing an fsm that needs the follow:
an Event named creating can goes to 3 different states (ok, unreachable, creating) depending on some checks. In order to realize this, I wrote a callback function like this one:
func (p *ClusterState) beforeCreating(e *fsm.Event) {
p.Logger.Infof("Triggered event %v, trying to reach status %s", e.Event, e.Dst)
if p.Unreachable {
timeLimit := p.CreatedAt.Add(time.Minute * 30)
if timeLimit.Before(p.Clock.Now()) {
e.FSM.SetState("CREATING") // it hangs here
}
}
}
Probably there is a better way to do that, or i am missing something.
Can anyone help me with that?
Thanks in advance!
I am writing an fsm that needs the follow:
an Event named
creatingcan goes to 3 different states (ok,unreachable,creating) depending on some checks. In order to realize this, I wrote a callback function like this one:Probably there is a better way to do that, or i am missing something.
Can anyone help me with that?
Thanks in advance!