Class: Sidekiq::PowerFetch::UnitOfWork

Inherits:
Object
  • Object
show all
Defined in:
lib/sidekiq/power_fetch/unit_of_work.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(queue, job) ⇒ UnitOfWork

Returns a new instance of UnitOfWork.



9
10
11
12
# File 'lib/sidekiq/power_fetch/unit_of_work.rb', line 9

def initialize(queue, job)
  @queue = queue
  @job = job
end

Instance Attribute Details

#jobObject (readonly)

Returns the value of attribute job.



7
8
9
# File 'lib/sidekiq/power_fetch/unit_of_work.rb', line 7

def job
  @job
end

#queueObject (readonly)

Returns the value of attribute queue.



6
7
8
# File 'lib/sidekiq/power_fetch/unit_of_work.rb', line 6

def queue
  @queue
end

Instance Method Details

#acknowledgeObject



14
15
16
17
18
# File 'lib/sidekiq/power_fetch/unit_of_work.rb', line 14

def acknowledge
  Sidekiq.redis do |conn|
    conn.lrem(PowerFetch.working_queue_name(@queue), 1, @job)
  end
end

#queue_nameObject



20
21
22
# File 'lib/sidekiq/power_fetch/unit_of_work.rb', line 20

def queue_name
  @queue.sub(/.*queue:/, "")
end

#requeueObject



24
25
26
27
28
29
30
31
# File 'lib/sidekiq/power_fetch/unit_of_work.rb', line 24

def requeue
  Sidekiq.redis do |conn|
    conn.multi do |multi|
      multi.lpush(@queue, @job)
      multi.lrem(PowerFetch.working_queue_name(@queue), 1, @job)
    end
  end
end