Class: Sidekiq::PowerFetch::UnitOfWork
- Inherits:
-
Object
- Object
- Sidekiq::PowerFetch::UnitOfWork
- Defined in:
- lib/sidekiq/power_fetch/unit_of_work.rb
Instance Attribute Summary collapse
-
#job ⇒ Object
readonly
Returns the value of attribute job.
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
Instance Method Summary collapse
- #acknowledge ⇒ Object
-
#initialize(queue, job) ⇒ UnitOfWork
constructor
A new instance of UnitOfWork.
- #queue_name ⇒ Object
- #requeue ⇒ Object
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
#job ⇒ Object (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 |
#queue ⇒ Object (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
#acknowledge ⇒ Object
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_name ⇒ Object
20 21 22 |
# File 'lib/sidekiq/power_fetch/unit_of_work.rb', line 20 def queue_name @queue.sub(/.*queue:/, "") end |
#requeue ⇒ Object
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 |