Hi, I am new to Temporal and I have a few questions about a scenario about long-running polling for a state, and for actions upon state transitions. After some research, I believe the following will work but would like some confirmation:
Workflow will have a local variable cur_state storing the current state. Then, while cur_state is not the end state, do the following: run a long-running polling activity (which uses heartbeats), passing in cur_state as the param. This activity will only complete when the polled state differs from the cur_state passed as a parameter. Now back to the workflow: the activity will return the polled_state, and this means there is a state transition from cur_state to polled_state, and thus the relevant action can be done. Then carry on with the while loop.
Questions:
-
If the activity worker dies midway, the value of parameter cur_state will be restored?
-
If we have very many workflows running at the same time, there will be many of these activities happening, when an activity sleeps (in between polling), will it be taking up the worker usage? That is, will activities be able to âyieldâ worker usage when they sleep? In general, should the problem of ânot enough workersâ be something to be worried about?
-
When workflow crashes, from what I researched, it seems that it will restart the whole workflow but since each activity result is stored, it will effectively skip through the activity and just return the result immediately to the flow. I want to confirm that the activity result stored is not just the latest call to the activity, but for each call previously made to the activity, and it will be able to return the correct results (i.e. first call result, second call result, etc)