Module: Resque::Plugins::Locket::Worker

Defined in:
lib/resque/plugins/locket/worker.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(receiver) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/resque/plugins/locket/worker.rb', line 6

def self.included(receiver)
  receiver.class_eval do
    alias queues_without_lock queues
    alias queues queues_with_lock

    alias reserve_and_clear_without_counter reserve
    alias reserve reserve_and_clear_counter
  end
end

Instance Method Details

#queues_with_lockObject

overwrite our original queues method with a new method that will check which of said queues were locked and not reserve jobs from those



18
19
20
21
22
# File 'lib/resque/plugins/locket/worker.rb', line 18

def queues_with_lock
  return queues_without_lock unless Resque.locket_enabled?

  queues_without_lock - locked_queues
end

#reserve_and_clear_counterObject



24
25
26
27
28
29
30
31
32
# File 'lib/resque/plugins/locket/worker.rb', line 24

def reserve_and_clear_counter
  return reserve_and_clear_without_counter unless Resque.locket_enabled?

  job = reserve_and_clear_without_counter

  redis.del("locket:queue_lock_counters") if job.nil?

  job
end