Sha256: da0bafb6df875bb66b4b2cdf4086443b67b3ee4518e9309e7d620456f893f29d

Contents?: true

Size: 820 Bytes

Versions: 8

Compression:

Stored size: 820 Bytes

Contents

# frozen_string_literal: true

module SidekiqUniqueJobs
  module Server
    class Middleware
      extend Forwardable
      def_delegators :Sidekiq, :logger
      def_instance_delegator :@worker, :class, :worker_class

      include OptionsWithFallback

      def call(worker, item, queue, redis_pool = nil, &blk)
        @worker = worker
        @redis_pool = redis_pool
        @queue = queue
        @item = item
        return yield unless unique_enabled?
        lock.send(:execute, after_unlock_hook, &blk)
      end

      private

      attr_reader :redis_pool, :worker, :item

      protected

      def after_unlock_hook
        -> { worker.after_unlock if worker.respond_to?(:after_unlock) }
      end

      def reschedule
        Sidekiq::Client.new(redis_pool).raw_push([item])
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
sidekiq-unique-jobs-5.0.11 lib/sidekiq_unique_jobs/server/middleware.rb
sidekiq-unique-jobs-5.0.10 lib/sidekiq_unique_jobs/server/middleware.rb
sidekiq-unique-jobs-5.0.9 lib/sidekiq_unique_jobs/server/middleware.rb
sidekiq-unique-jobs-5.0.8 lib/sidekiq_unique_jobs/server/middleware.rb
sidekiq-unique-jobs-5.0.7 lib/sidekiq_unique_jobs/server/middleware.rb
sidekiq-unique-jobs-5.0.6 lib/sidekiq_unique_jobs/server/middleware.rb
sidekiq-unique-jobs-5.0.5 lib/sidekiq_unique_jobs/server/middleware.rb
sidekiq-unique-jobs-5.0.4 lib/sidekiq_unique_jobs/server/middleware.rb