Skip to content

when I use SetState in a callback in a before_<event> => deadlock #87

Description

@lzecca78

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!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions