Sha256: f693209a91257f36493824bc30ee5de5ed1776312937e66ffae1efa635310595

Contents?: true

Size: 1.14 KB

Versions: 18

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true

module SidekiqUniqueJobs
  module Middleware
    # The unique sidekiq middleware for the client push
    #
    # @author Mikael Henriksson <mikael@mhenrixon.com>
    class Client
      include Sidekiq::ClientMiddleware if defined?(Sidekiq::ClientMiddleware)

      # prepend "SidekiqUniqueJobs::Middleware"
      # @!parse prepends SidekiqUniqueJobs::Middleware
      prepend SidekiqUniqueJobs::Middleware
      # includes "SidekiqUniqueJobs::Reflectable"
      # @!parse include SidekiqUniqueJobs::Reflectable
      include SidekiqUniqueJobs::Reflectable

      # Calls this client middleware
      #   Used from Sidekiq.process_single
      #
      # @see SidekiqUniqueJobs::Middleware#call
      #
      # @see https://github.com/mperham/sidekiq/wiki/Job-Format
      # @see https://github.com/mperham/sidekiq/wiki/Middleware
      #
      # @yield when uniqueness is disable
      # @yield when the lock is successful
      def call(*, &block)
        lock(&block)
      end

      private

      def lock
        lock_instance.lock do
          reflect(:locked, item)
          return yield
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
sidekiq-unique-jobs-7.1.33 lib/sidekiq_unique_jobs/middleware/client.rb
sidekiq-unique-jobs-7.1.32 lib/sidekiq_unique_jobs/middleware/client.rb
sidekiq-unique-jobs-8.0.7 lib/sidekiq_unique_jobs/middleware/client.rb
sidekiq-unique-jobs-8.0.6 lib/sidekiq_unique_jobs/middleware/client.rb
sidekiq-unique-jobs-7.1.31 lib/sidekiq_unique_jobs/middleware/client.rb
sidekiq-unique-jobs-8.0.5 lib/sidekiq_unique_jobs/middleware/client.rb
sidekiq-unique-jobs-8.0.4 lib/sidekiq_unique_jobs/middleware/client.rb
sidekiq-unique-jobs-7.1.30 lib/sidekiq_unique_jobs/middleware/client.rb
sidekiq-unique-jobs-8.0.3 lib/sidekiq_unique_jobs/middleware/client.rb
sidekiq-unique-jobs-8.0.2 lib/sidekiq_unique_jobs/middleware/client.rb
sidekiq-unique-jobs-8.0.1 lib/sidekiq_unique_jobs/middleware/client.rb
sidekiq-unique-jobs-8.0.0 lib/sidekiq_unique_jobs/middleware/client.rb
sidekiq-unique-jobs-7.1.29 lib/sidekiq_unique_jobs/middleware/client.rb
sidekiq-unique-jobs-7.1.28 lib/sidekiq_unique_jobs/middleware/client.rb
sidekiq-unique-jobs-7.1.27 lib/sidekiq_unique_jobs/middleware/client.rb
sidekiq-unique-jobs-7.1.26 lib/sidekiq_unique_jobs/middleware/client.rb
sidekiq-unique-jobs-7.1.25 lib/sidekiq_unique_jobs/middleware/client.rb
sidekiq-unique-jobs-7.1.24 lib/sidekiq_unique_jobs/middleware/client.rb