qmuntal / stateless

Go library for creating finite state machines
BSD 2-Clause "Simplified" License
894 stars 47 forks source link

Please add the ability to reuse a state machine #79

Open scr-oath opened 2 days ago

scr-oath commented 2 days ago

I would like to use a state machine for a complicated logic flow for every request of a server - mainly to self-document (the graphviz stuff) and it would be really nice to make a new state machine from an existing archetype of sorts. Merely cloning one in its initial state would be great!

scr-oath commented 2 days ago

If you're feeling really creative, you could make an interface for a state machine instance and keep a pointer to the machine and just the state can be copied to a new instance

scr-oath commented 16 hours ago

Another idea - is to provide a very fast reset call and use sync.Pool to "reuse"