Sha256: 23c03782d789f56d89be2ba08bd7e62b9ebb8c925eb96e36082317f5191ba3f6

Contents?: true

Size: 1.26 KB

Versions: 8

Compression:

Stored size: 1.26 KB

Contents

# frozen_string_literal: true

module SidekiqUniqueJobs
  #
  # Provides the sidekiq middleware that makes the gem work
  #
  # @author Mikael Henriksson <mikael@mhenrixon.com>
  #
  module Middleware
    include SidekiqUniqueJobs::Logging::Middleware
    include SidekiqUniqueJobs::OptionsWithFallback
    include SidekiqUniqueJobs::JSON

    # The sidekiq job hash
    # @return [Hash] the Sidekiq job hash
    attr_reader :item

    #
    # This method runs before (prepended) the actual middleware implementation.
    #   This is done to reduce duplication
    #
    # @param [Sidekiq::Worker] worker_class
    # @param [Hash] item a sidekiq job hash
    # @param [String] queue name of the queue
    # @param [ConnectionPool] redis_pool only used for compatility reasons
    #
    # @return [yield<super>] <description>
    #
    # @yieldparam [<type>] if <description>
    # @yieldreturn [<type>] <describe what yield should return>
    def call(worker_class, item, queue, redis_pool = nil)
      @item       = item
      @queue      = queue
      @redis_pool = redis_pool
      self.job_class = item[CLASS]
      return yield if unique_disabled?

      SidekiqUniqueJobs::Job.prepare(item) unless item[LOCK_DIGEST]

      with_logging_context do
        super
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
sidekiq-unique-jobs-7.1.28 lib/sidekiq_unique_jobs/middleware.rb
sidekiq-unique-jobs-7.1.27 lib/sidekiq_unique_jobs/middleware.rb
sidekiq-unique-jobs-7.1.26 lib/sidekiq_unique_jobs/middleware.rb
sidekiq-unique-jobs-7.1.25 lib/sidekiq_unique_jobs/middleware.rb
sidekiq-unique-jobs-7.1.24 lib/sidekiq_unique_jobs/middleware.rb
sidekiq-unique-jobs-7.1.23 lib/sidekiq_unique_jobs/middleware.rb
sidekiq-unique-jobs-7.1.22 lib/sidekiq_unique_jobs/middleware.rb
sidekiq-unique-jobs-7.1.21 lib/sidekiq_unique_jobs/middleware.rb