mperham/sidekiq — Issue #66: Add support for scheduling jobs to run at a particular time in the future
Author: ryanlecompte
Created: 2012-03-01 05:38:10+00:00
State: open

@robgleeson recently wrote a gem that provides new middleware for executing jobs at a particular time in the future. Unfortunately I don't think this is appropriate as middleware since it involves re-scheduling the job back into the 'scheduled' queue if it's not the appropriate time to run the job. You can see this here:

https://github.com/robgleeson/sidekiq-scheduler/blob/master/lib/sidekiq-scheduler/middleware.rb

Furthermore, the gem makes direct use of Sidekiq classes that aren't meant to be utilized outside of the core library.

After talking to @robgleeson, we think it makes sense to try and add this support directly to Sidekiq. This is quite similar to delayed_job's ability to run jobs in the future, e.g.:

```ruby
Delayed::Job.enqueue(:payload_object => ['foo'], :run_at => 5.days.from_now)
```

Mike, any thoughts on this? Is this something you'd like to be handled by sidekiq core? I'm thinking that Sidekiq::Manager#find_work could handle jobs in the special "scheduled" queue a bit differently, and instead of actually removing them from the queue, it essentially just peeks at them to see if they should be popped off the queue and executed. It probably doesn't need to support the same weight semantics that we currently have in place, but would just be a special worker (or set of workers) that always check this special queue for items that should be executed by doing a simple date comparison like in the link above.

Thoughts?