Sha256: 1839f89bd591f059e63dc0c1a3344160d0669f5408e759651ed7086cf85e86ff

Contents?: true

Size: 578 Bytes

Versions: 1

Compression:

Stored size: 578 Bytes

Contents

module AtomicSidekiq
  class InFlightKeymaker
    def initialize(key_prefix)
      @key_prefix = key_prefix
    end

    def queue_prefix(queue)
      normalized_name = queue.gsub(/queue:/, "")
      "#{key_prefix}:#{normalized_name}:"
    end

    def queue_matcher(queue)
      "#{queue_prefix(queue)}*"
    end

    def job_key(job)
      obj = job
      obj = JSON.parse(obj) if job.is_a?(String)
      "#{key_prefix}:#{obj['queue']}:#{obj['jid']}"
    end

    def job_matcher(jid)
      "#{key_prefix}:*:#{jid}"
    end

    private

    attr_reader :key_prefix
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
atomic-sidekiq-1.1.0 lib/atomic_sidekiq/in_flight_keymaker.rb