Sha256: 05b4e60569454c06cf9725cf2424457acfb9c7fe51c162ef472f431be0389baa

Contents?: true

Size: 1.08 KB

Versions: 6

Compression:

Stored size: 1.08 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
      # 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 |_locked_jid|
          reflect(:locked, item)
          return yield
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sidekiq-unique-jobs-7.1.6 lib/sidekiq_unique_jobs/middleware/client.rb
sidekiq-unique-jobs-7.1.5 lib/sidekiq_unique_jobs/middleware/client.rb
sidekiq-unique-jobs-7.1.3 lib/sidekiq_unique_jobs/middleware/client.rb
sidekiq-unique-jobs-7.1.2 lib/sidekiq_unique_jobs/middleware/client.rb
sidekiq-unique-jobs-7.1.1 lib/sidekiq_unique_jobs/middleware/client.rb
sidekiq-unique-jobs-7.1.0 lib/sidekiq_unique_jobs/middleware/client.rb