Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Disable extensions when Resque.inline? == true #12

Merged
merged 1 commit into from

2 participants

@arthurdandrea

There is no point in ensuring that jobs are unique if there are only one job executing at a time. This fixes specs and tests that depend on Resque.inline? == true.

@arthurdandrea arthurdandrea disable extensions if Resque.inline? fix #11
if Resque.inline? jobs are executed inline (duh) and there is no concurrency, no resque-loner
2aed253
@jayniz jayniz commented on the diff
lib/resque-ext/job.rb
@@ -12,11 +12,15 @@ module Resque
# 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?
@jayniz Owner
jayniz added a note

I'd personally do it like this:

def self.create_with_loner(queue, klass, *args)
  return create_without_loner(queue, klass, *args) if Resque.inline?
  ...
end

But will merge like that unless you want to change it ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@jayniz jayniz merged commit 712b259 into resque:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 5, 2011
  1. @arthurdandrea

    disable extensions if Resque.inline? fix #11

    arthurdandrea authored
    if Resque.inline? jobs are executed inline (duh) and there is no concurrency, no resque-loner
This page is out of date. Refresh to see the latest.
Showing with 11 additions and 7 deletions.
  1. +11 −7 lib/resque-ext/job.rb
View
18 lib/resque-ext/job.rb
@@ -12,11 +12,15 @@ 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?
@jayniz Owner
jayniz added a note

I'd personally do it like this:

def self.create_with_loner(queue, klass, *args)
  return create_without_loner(queue, klass, *args) if Resque.inline?
  ...
end

But will merge like that unless you want to change it ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ 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
#
@@ -24,7 +28,7 @@ def self.create_with_loner(queue, klass, *args)
#
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
Something went wrong with that request. Please try again.