bull icon indicating copy to clipboard operation
bull copied to clipboard

Enhancement: Recurrence Rule (rfc 5545, "rrule") support for repeating jobs

Open adamlounds opened this issue 3 years ago • 1 comments

Enhancement Request

Support rrule (rfc5545) syntax as well as cron syntax for repeating jobs

paymentsQueue.add(paymentsData, {repeat: {rrule: 'DTSTART:20210401T23:59:59Z\nFREQ=DAILY;COUNT=2'}});

Recurrence rules are much more flexible than cron specifications, supporting things like "every monday and wednesday", or "the last thursday of the month, for five months". There's a js library to parse/validate rrules, which can generate the next Date the job should be run via

const rrule = rrulestr('DTSTART:20120201T023000Z\nRRULE:FREQ=MONTHLY;COUNT=5')
const nextRun = rrule.after(new Date);

This should be reasonably straightforward to add to getNextMillis, but rrule has some "quirks" if the system is not set to run in the UTC timezone.

adamlounds avatar Mar 01 '21 10:03 adamlounds

I am using this temporarily

emanuelet avatar Jan 13 '22 02:01 emanuelet