Skip to content

How to stop FSM execution #77

@paveq

Description

@paveq

I'm creating workflow execution using the stateless FSM behind the scene. In the execution I need to keep track of number of transitions, and halt the execution if that count is ever exceeded, in order to prevent runaway situations.

I have a struct to keep track of number of transitions happened in the FSM:

type ResetOperation struct {
	fsm                     *stateless.StateMachine
	transitionCount int32
}

To increment transitionCount I'm using OnTransitioning() handler. However, there seems to be no way to return error from the handler function, and calling fsm.Deactive() will not stop the execution.

I could probably fire trigger "maxTransitionsReached" and have an error state in the FSM, but if I understand correctly, firing the trigger will cause it to be put on queue fireModeQueued, and queue might not be empty.

What is proper way to handle this scenario?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions