Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to stop FSM execution #77

Open
paveq opened this issue Apr 18, 2024 · 0 comments
Open

How to stop FSM execution #77

paveq opened this issue Apr 18, 2024 · 0 comments

Comments

@paveq
Copy link

paveq commented Apr 18, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant