Sha256: 6a14eb1e458b16f0649d097b849a85b6d54a4567b57e2021eadeb4edc72d885f

Contents?: true

Size: 705 Bytes

Versions: 3

Compression:

Stored size: 705 Bytes

Contents

module AtomicSidekiq
  class UnitOfWork
    attr_reader :queue, :job

    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

    def acknowledge
      acknowledge_op.perform(job: job)
    end

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

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

    private

    attr_reader :acknowledge_op, :requeue_op
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
atomic-sidekiq-1.3.0 lib/atomic_sidekiq/unit_of_work.rb
atomic-sidekiq-1.2.0 lib/atomic_sidekiq/unit_of_work.rb
atomic-sidekiq-1.1.4 lib/atomic_sidekiq/unit_of_work.rb