Skip to content

Commit

Permalink
Added Delayed::Job.reserve for a cleaner way to find and lock one ava…
Browse files Browse the repository at this point in the history
…ilable job
  • Loading branch information
bkeepers authored and betamatt committed Nov 29, 2010
1 parent 87ff897 commit 63a987d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/delayed/backend/base.rb
Expand Up @@ -20,7 +20,13 @@ def enqueue(*args)
run_at = args[1]
self.create(:payload_object => object, :priority => priority.to_i, :run_at => run_at)
end


def reserve(worker, max_run_time = Worker.max_run_time)
find_available(worker, 5, max_run_time).detect do |job|
job.lock_exclusively!(max_run_time, worker)
end
end

# Hook method that is called before a new worker is forked
def before_fork
end
Expand Down

0 comments on commit 63a987d

Please sign in to comment.