gocron
gocron copied to clipboard
[FEATURE] - supports job retry when job failed
Is your feature request related to a problem? Please describe
I am not sure if gocron has the feature of the retry when the job failed. I can't find this feature.
Describe the solution you'd like
Hope that there is a feature that when my job return an error, i can catch this error in gocron, and decide if i should retry this job by something like gocron.DoOnce(job).
Describe alternatives you've considered
Additional context
maybe there can be some strategies that gocron can provide to make developer choose rather than a simple retry.Thanks.
Hi @Shawn-Huang-Tron,
There is not currently any sort of retry logic supported in gocron. In general, I assume users today are handling any sort retry logic inside the job itself rather than returning an error.
I could see a feature like this working in a couple ways:
- A simple option to retry the job x times when any error is returned from the job
- A next iteration could include allowing which errors it should be retried upon
- A further iteration could be specifying more complex options like retry interval and backoff
"A simple option to retry the job x times when any error is returned from the job" sounds like good and simple. But maybe the behavior of retry can be handled by the developer will be better. Gocron just like a scheduler, developer put and subscribe jobs in gocron, and if job failed, then the developer will get an error about this job.And at that time,developer can choose that if he want to run this job again.