I’m creating a long-running entity workflow as described at Very Long-Running Workflows | Temporal Technologies. What is the best way to implement the functionality described in that post as “Wait for Billing Period”? For example, lets say I want a workflow to do something every Friday at 7pm.
The approaches I have considered are:
Approach 1 would be to simply Workflow.sleep
for a duration equal to the target time minus the current time.
Approach 2 would be to create a separate scheduled workflow that runs at the target time, and sends the entity workflow a signal which causes it to start its work.
Any other good approaches to this?
Related to this is perhaps the requirement to insert a new activity in between the current time and the next scheduled action for the entity.
With approach 1, would changing the sleep time to a lower value and adding a new action before the one the sleep is currently waiting on (still for some time in the future, so no previous activities are affected) be an indeterministic change?
The same scenario with adding a new signal using approach #2 would I think be no problem.
Which approach is easier to manage long-term?
Thanks!