Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions lib/resque_unit/scheduler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,15 @@ module Scheduler
# for queueing. Until timestamp is in the past, the job will
# sit in the schedule list.
def enqueue_at(timestamp, klass, *args)
enqueue_with_timestamp(timestamp, klass, *args)
enqueue_with_timestamp(queue_for(klass), timestamp, klass, *args)
end

# Identical to +enqueue_at+, except you can also specify
# a queue in which the job will be placed after the
# timestamp has passed. It respects Resque.inline option, by
# creating the job right away instead of adding to the queue.
def enqueue_at_with_queue(queue, timestamp, klass, *args)
enqueue_with_timestamp(queue, timestamp, klass, *args)
end

# Identical to enqueue_at but takes number_of_seconds_from_now
Expand All @@ -18,10 +26,9 @@ def enqueue_in(number_of_seconds_from_now, klass, *args)
enqueue_at(Time.now + number_of_seconds_from_now, klass, *args)
end

def enqueue_with_timestamp(timestamp, klass, *args)
enqueue_unit(queue_for(klass), {"class" => klass.name, "args" => args, "timestamp" => timestamp})
def enqueue_with_timestamp(queue, timestamp, klass, *args)
enqueue_unit(queue, {"class" => klass.name, "args" => args, "timestamp" => timestamp})
end

def remove_delayed(klass, *args)
# points to real queue
encoded_job_payloads = Resque.queue(queue_for(klass))
Expand Down