vsivsi / meteor-job-collection

A persistent and reactive job queue for Meteor, supporting distributed workers that can run anywhere.
https://atmospherejs.com/vsivsi/job-collection
Other
388 stars 68 forks source link

workTimeout / next repeat #204

Open jensvrai opened 7 years ago

jensvrai commented 7 years ago

I have a questions about job.fail() and repeats. We currently have some long running jobs, which wait for feedback from external services but sometimes it never comes. So we used the workTimeout option when calling processJobs. But we also defined a repeat schedule for the job, so it runs everyday. Is there an options that when a job fails, it is rescheduled based on the repeat schedule? Like it does when job.done is called?

vsivsi commented 7 years ago

Probably the easiest way to do this is to also specify a retry() on the job that matches the desired repeat frequency. Retry is not as flexible as repeat, but for the case you describe it should suffice by simply specifying each retry to be 1 day minus your workTimeout value. If you specify infinite retries, it will retry once per day and when it finally succeeds, the next repeat will automatically occur as scheduled.