Sha256: 3f97758ba2d9437069a72a9e53b95f0d94b6136692132150917b86c116e1ca25

Contents?: true

Size: 710 Bytes

Versions: 1

Compression:

Stored size: 710 Bytes

Contents

module AtomicSidekiq
  class UnitOfWork
    attr_reader :queue, :job

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

    def acknowledge
      acknowledge_op.perform(queue: queue, job: job)
    end

    def queue_name
      "queue:#{queue.sub(/.*queue:/, '')}"
    end

    def requeue
      requeue_op.perform(queue: queue, job: job)
    end

    private

    attr_reader :acknowledge_op, :requeue_op
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
atomic-sidekiq-1.0.0 lib/atomic_sidekiq/unit_of_work.rb