sibson / redbeat

RedBeat is a Celery Beat Scheduler that stores the scheduled tasks and runtime metadata in Redis.
Apache License 2.0
924 stars 131 forks source link

Support for iCal recurrence rules (RRULE) #60

Closed concreted closed 7 years ago

concreted commented 7 years ago

I would like to add support for schedules defined with RRules based on the iCal RFC (https://icalendar.org/iCalendar-RFC-5545/3-8-5-3-recurrence-rule.html). I think the scope of work involved would be:

  1. Implement a RRuleSchedule class that inherits from celery.schedules.BaseSchedule and implements remaining_estimate and is_due methods (using dateutil.rrule)
  2. Update RedBeatJSONDecoder and RedBeatJSONEncoder to handle the new class
  3. To handle RRules that end after a certain date/after a certain number of occurrences, add a way to mark schedules as 'inactive' after its last occurrence, so Redbeat will ignore them. Not sure exactly what this looks like yet

@sibson How does this sound to you? Does the scope of work look accurate or is there anything else that would be needed? Interested in your thoughts on how to best implement point 3.

I'm actively working on a project using Redbeat, and having RRULE support directly in Redbeat would make things easier for my use case (avoid having to convert RRULEs to cron timings, being able to let Redbeat take care of schedules that end after some time instead of adding logic externally). If you think this is worth doing in mainline Redbeat I can have a WIP PR later this week for you to look at.

sibson commented 7 years ago

I'm not familiar with RRules, so will need to take some time to review the docs you've helpfully linked to.

Have you considered adding this to core celery?

concreted commented 7 years ago

One of the features of RRules is that they can have an end date/fixed number of occurrences, which doesn't happen in any of the schedule classes in core celery - i.e. calling due_at will always return a time in the future. I think adding RRules to celery is a good idea that I will look into, but we would still have to handle the schedule ending in Redbeat.

sibson commented 7 years ago

closed by #61