Ash state machine with timeouts

Does ash_state_machine support timeouts? Is there a minimal example around it ?

Ash state machine is backed by wherever persistence the resource uses, not by a genserver/process (although there is a genserver data layer in GH). What kind of timeout do you have in mind?

if I stay too long in waiting state, I want to retry my_previsou_state. After max retries => the process to move to stop state.

This isn’t built in to AshStateMachine, no. But you can implement this yourself in any number of ways. Folks often use AshOban to automate around their state machines, but that is only good when your granularity is higher than 1 minute.


Thanks for the reply.

What you can also do is create a genserver responsible for moving the underlying resource between states, and then put some timeout rules in the genserver. Keep in mind that won’t survive restarts and that kind of thing, but its another option for state machines on a tight loop.