Friday, December 10, 2010

resque-scheduler 2.0.0 pre

Moved here

I just push resque-scheduler 2.0.0.a.
  gem install resque-scheduler --pre
It contains some interesting changes from brianjlandua and davidyang. The gist of it is, you can now schedule items dynamically. Here's what it looks like: Let's say you want your users to configure when some report is generated. You can do something like this:
  Resque.set_schedule('user_16_report', {
    :cron => "0 1 * * *",
    :queue => "reports",
    :class => "GenerateUserReport",
    :args => 16})
That creates a scheduled job and takes effect immediately. This is accomplished by storing the schedule state in a redis hash (so, yes, >=1.3 redis is required) and marking changes in an ordered set. The schedule process looks for changes in the ordered set and then applies them during each loop. The scheduler tab in resque-web will also pull the schedule from redis, so you can see what's currently scheduled. This behavior is not default. You need to set this (for the scheduler process and resque-web):
  Resque::Scheduler.dynamic = true
By default, resque-scheduler behaves as it always has (other than storing the schedule in redis). This functionality just opens up new possibilities for scheduling jobs.

No comments: