hekailiang / squirrel

squirrel-foundation is a State Machine library, which provided a lightweight, easy use, type safe and programmable state machine implementation for Java.
http://hekailiang.github.io/squirrel/
Other
2.19k stars 540 forks source link

How to decline transition #101

Open argoyb opened 5 years ago

argoyb commented 5 years ago

Documentation says there is a listener @OnTransitionDecline, however I can't find anything on how to trigger transition decline.

To give some context use case I'm working on right now: running computation in another service. There are four states: SUBMITTED - submits item to another system - IN PROGRESS - checks the status of item in another system. If still in progress state is not changed, if done -DONE or if failed -FAILED. One way to model it is while in IN PROGRESS state make a request to another service, if request is in progress - deny transition (stay in same IN PROGRESS state), if ok - move to DONE, if failed - move to FAILED. Actually in addition to unclear way how to decline transition it also seems to be not possible to move to either DONE or FAILED state.

How would you recommend to model this problem with FSM? Thanks.