Sha256: 6e928e4ba82a1d66821cb7bbbb4a445a3e1e963ed6ee952aee57b7711e60accf

Contents?: true

Size: 874 Bytes

Versions: 9

Compression:

Stored size: 874 Bytes

Contents

# frozen_string_literal: true

module SidekiqUniqueJobs
  module Server
    # The unique sidekiq middleware for the server processor
    #
    # @author Mikael Henriksson <mikael@zoolutions.se>
    class Middleware
      include OptionsWithFallback

      # Runs the server middleware
      #   Used from Sidekiq::Processor#process
      # @param [Sidekiq::Worker] worker_class
      # @param [Hash] item a sidekiq job hash
      # @param [String] queue name of the queue
      # @yield when uniqueness is disabled
      # @yield when the lock class executes successfully
      def call(worker_class, item, queue)
        @worker_class = worker_class
        @item         = item
        @queue        = queue
        return yield if unique_disabled?

        lock.execute do
          yield
        end
      end

      protected

      attr_reader :item
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
sidekiq-unique-jobs-6.0.6 lib/sidekiq_unique_jobs/server/middleware.rb
sidekiq-unique-jobs-6.0.5 lib/sidekiq_unique_jobs/server/middleware.rb
sidekiq-unique-jobs-6.0.4 lib/sidekiq_unique_jobs/server/middleware.rb
sidekiq-unique-jobs-6.0.3 lib/sidekiq_unique_jobs/server/middleware.rb
sidekiq-unique-jobs-6.0.2 lib/sidekiq_unique_jobs/server/middleware.rb
sidekiq-unique-jobs-6.0.1 lib/sidekiq_unique_jobs/server/middleware.rb
sidekiq-unique-jobs-6.0.0 lib/sidekiq_unique_jobs/server/middleware.rb
sidekiq-unique-jobs-6.0.0.rc8 lib/sidekiq_unique_jobs/server/middleware.rb
sidekiq-unique-jobs-6.0.0.rc7 lib/sidekiq_unique_jobs/server/middleware.rb