Possible to Implement Finite State Machine using Workflows?

Doesn’t signals break deterministic behavior always ?
If there is a crash, and when the qorkflow gets restored, will it replay receiving the signal also if there was a signal before the crash ?

I don’t understand your question. Nondeterministic workflow code can break determinism. For example, a code that makes external API requests directly without activities or relying on a random generator to decide which step to take next. Signals are recorded in the workflow execution history and never break determinism. So I’m not sure what do you mean by " Doesn’t signals break deterministic behavior always ?".

( Sorry I was not clear earlier )

Oh I did not know this ( “Signals are recorded in the workflow execution history and never break determinism” )

Thank you Maxim

1 Like

Is my understanding correct this time?

pulling through external API call in an activity is deterministic (whereas pulling external API directly in workflow is non deterministic) because history service record both input and output of an activity, so it is able to snapshot the old state of external API even when the external API is changing its output overtime.

Yes, this is correct. Note that external service returning value the first time and error second time is even more common than returning a different output.

1 Like