Sha256: ac4a43ed33c26480b9882fc66978df29ecc948e89b9d84ee4423268dc5a0bc7d

Contents?: true

Size: 1.27 KB

Versions: 33

Compression:

Stored size: 1.27 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)
      @worker_class = worker_class
      @item         = item
      @queue        = queue
      @redis_pool   = redis_pool
      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

33 entries across 33 versions & 1 rubygems

Version Path
sidekiq-unique-jobs-7.1.20 lib/sidekiq_unique_jobs/middleware.rb
sidekiq-unique-jobs-7.1.19 lib/sidekiq_unique_jobs/middleware.rb
sidekiq-unique-jobs-7.1.18 lib/sidekiq_unique_jobs/middleware.rb
sidekiq-unique-jobs-7.1.17 lib/sidekiq_unique_jobs/middleware.rb
sidekiq-unique-jobs-7.1.16 lib/sidekiq_unique_jobs/middleware.rb
sidekiq-unique-jobs-7.1.15 lib/sidekiq_unique_jobs/middleware.rb
sidekiq-unique-jobs-7.1.14 lib/sidekiq_unique_jobs/middleware.rb
sidekiq-unique-jobs-7.1.13 lib/sidekiq_unique_jobs/middleware.rb
sidekiq-unique-jobs-7.1.12 lib/sidekiq_unique_jobs/middleware.rb
sidekiq-unique-jobs-7.1.11 lib/sidekiq_unique_jobs/middleware.rb
sidekiq-unique-jobs-7.1.10 lib/sidekiq_unique_jobs/middleware.rb
sidekiq-unique-jobs-7.1.8 lib/sidekiq_unique_jobs/middleware.rb
sidekiq-unique-jobs-7.0.13 lib/sidekiq_unique_jobs/middleware.rb
sidekiq-unique-jobs-7.1.7 lib/sidekiq_unique_jobs/middleware.rb
sidekiq-unique-jobs-7.1.6 lib/sidekiq_unique_jobs/middleware.rb
sidekiq-unique-jobs-7.1.5 lib/sidekiq_unique_jobs/middleware.rb
sidekiq-unique-jobs-7.1.3 lib/sidekiq_unique_jobs/middleware.rb
sidekiq-unique-jobs-7.1.2 lib/sidekiq_unique_jobs/middleware.rb
sidekiq-unique-jobs-7.1.1 lib/sidekiq_unique_jobs/middleware.rb
sidekiq-unique-jobs-7.1.0 lib/sidekiq_unique_jobs/middleware.rb