Permalink
Browse files

disable extensions if Resque.inline? fix #11

if Resque.inline? jobs are executed inline (duh) and there is no concurrency, no resque-loner
  • Loading branch information...
1 parent f977f07 commit 2aed253b9a7dd3fbcbb71905255b0a4eedb25909 @arthurdandrea arthurdandrea committed Aug 5, 2011
Showing with 11 additions and 7 deletions.
  1. +11 −7 lib/resque-ext/job.rb
View
@@ -12,19 +12,23 @@ class Job
# after Resque::Job.create has called Resque.push
#
def self.create_with_loner(queue, klass, *args)
- item = { :class => klass.to_s, :args => args }
- return "EXISTED" if Resque::Plugins::Loner::Helpers.loner_queued?(queue, item)
- job = create_without_loner(queue, klass, *args)
- Resque::Plugins::Loner::Helpers.mark_loner_as_queued(queue, item)
- job
+ if Resque.inline?
+ create_without_loner(queue, klass, *args)
+ else
+ item = { :class => klass.to_s, :args => args }
+ return "EXISTED" if Resque::Plugins::Loner::Helpers.loner_queued?(queue, item)
+ job = create_without_loner(queue, klass, *args)
+ Resque::Plugins::Loner::Helpers.mark_loner_as_queued(queue, item)
+ job
+ end
end
#
# Overwriting original reserve method to mark an item as unqueued
#
def self.reserve_with_loner(queue)
item = reserve_without_loner(queue)
- Resque::Plugins::Loner::Helpers.mark_loner_as_unqueued( queue, item ) if item
+ Resque::Plugins::Loner::Helpers.mark_loner_as_unqueued( queue, item ) if item && !Resque.inline?
item
end
@@ -35,7 +39,7 @@ def self.reserve_with_loner(queue)
# as the original method Resque::Job.destroy. Couldn't make it any dry'er.
#
def self.destroy_with_loner(queue, klass, *args)
- Resque::Plugins::Loner::Helpers.job_destroy(queue, klass, *args)
+ Resque::Plugins::Loner::Helpers.job_destroy(queue, klass, *args) unless Resque.inline?
destroy_without_loner(queue, klass, *args)
end

0 comments on commit 2aed253

Please sign in to comment.