cschleiden / go-workflows

Embedded durable workflows for Golang similar to DTFx/Cadence/Temporal
https://cschleiden.github.io/go-workflows/
MIT License
218 stars 50 forks source link

How set a timeout so that a activity task execution becomes stale #358

Closed rullyalves closed 2 months ago

rullyalves commented 2 months ago

there are use cases where a workflow can be started, paused for a long time and then resume execution, if an activity calculates a volatile value, such as a user's account balance, is there any way to restart the workflow if it takes a long time to execute? I thought about using "continueAsNew" for this, but it would restart the entire workflow and not just specific activities

It could be interesting to allow a parameter or a timeout where after resuming workflow execution, certain tasks become "stale" and are recalculated

If this change makes sense, I would like to try to contribute a PR to support this use case

cschleiden commented 2 months ago

I think you also asked about this in a discussion? I'm not quite sure about the scenario.

You could manually keep the timestamp together with the calculcation result from your activity. Then, once your workflow resumes and the value is too old you can recompute it.