Class: AtomicSidekiq::UnitOfWork

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(queue = nil, job = nil, in_flight_keymaker:) ⇒ UnitOfWork

Returns a new instance of UnitOfWork.



5
6
7
8
9
10
11
12
13
14
# File 'lib/atomic_sidekiq/unit_of_work.rb', line 5

def initialize(queue = nil, job = nil, in_flight_keymaker:)
  @queue          = queue
  @job            = job
  @acknowledge_op = AtomicOperation::Acknowledge.new(
    in_flight_keymaker: in_flight_keymaker
  )
  @requeue_op = AtomicOperation::Requeue.new(
    in_flight_keymaker: in_flight_keymaker
  )
end

Instance Attribute Details

#jobObject (readonly)

Returns the value of attribute job.



3
4
5
# File 'lib/atomic_sidekiq/unit_of_work.rb', line 3

def job
  @job
end

#queueObject (readonly)

Returns the value of attribute queue.



3
4
5
# File 'lib/atomic_sidekiq/unit_of_work.rb', line 3

def queue
  @queue
end

Instance Method Details

#acknowledgeObject



16
17
18
# File 'lib/atomic_sidekiq/unit_of_work.rb', line 16

def acknowledge
  acknowledge_op.perform(job: job)
end

#queue_nameObject



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

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

#requeueObject



24
25
26
# File 'lib/atomic_sidekiq/unit_of_work.rb', line 24

def requeue
  requeue_op.perform(queue: "queue:#{queue_name}", job: job)
end