Rescheduling a job #645

Closed
laserlemon opened this Issue Jan 25, 2013 · 7 comments

Projects

None yet

3 participants

@laserlemon
Contributor

I'm new to Sidekiq but I'm really enjoying it so far. Thank you for your great work!

I'm planning to use Sidekiq for scheduling jobs to run in the future. But between when a job is created and when it runs, I want the ability to reschedule the job.

In my case, I'm enqueuing the job when I create a user. I can store the job's ID alongside the user model so I can reference it later. I'm wondering how I can use that ID to fetch the job and change its scheduled run time.

I'd love to put in the work to make this easier if I could get some direction on what the API should look like. Any thoughts?

Thank you!

@mperham
Owner
mperham commented Jan 25, 2013

Writing an API like so should be easy:

# Sidekiq::ScheduledSet.new.reschedule('12356', :in => 3.minutes)
def reschedule(jid, opts)
end
@laserlemon
Contributor

Perfect. I'll give it a shot. Thank you!

@laserlemon
Contributor

I'm a little confused as to how score factors in here. I don't see any code that fetches an existing job by the jid alone.

@brandonhilkert
Collaborator

It's a timestamp basically to support ordering.


http://brandonhilkert.com

On Fri, Jan 25, 2013 at 10:04 AM, Steve Richert notifications@github.comwrote:

I'm a little confused as to how score factors in here. I don't see any
code that fetches an existing job by the jid alone.


Reply to this email directly or view it on GitHubhttps://github.com/mperham/sidekiq/issues/645#issuecomment-12704123.

@mperham
Owner
mperham commented Jan 25, 2013

The schedule set is sorted by execution time stamp. You need to iterate through the whole thing, find the job, remove it and reschedule with the new time stamp.

On 25 Jan 2013, at 07:04, Steve Richert notifications@github.com wrote:

I'm a little confused as to how score factors in here. I don't see any code that fetches an existing job by the jid alone.


Reply to this email directly or view it on GitHub.

@laserlemon
Contributor

I'm having a hard time following the code and I'm not very familiar with how to interact with Redis. I might be in over my head here, although I still think that the ability to reschedule a job would be a nice feature.

@mperham mperham closed this in 1f431cb Jan 29, 2013
@laserlemon
Contributor

🤘

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment