Sha256: 8661b1815bd2438a493159a6aea4db97d5bbde3b9f5e8f1fbb6824d719cb9c1a

Contents?: true

Size: 804 Bytes

Versions: 3

Compression:

Stored size: 804 Bytes

Contents

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, :worker_class

      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

3 entries across 3 versions & 1 rubygems

Version Path
sidekiq-unique-jobs-4.0.13 lib/sidekiq_unique_jobs/server/middleware.rb
sidekiq-unique-jobs-4.0.12 lib/sidekiq_unique_jobs/server/middleware.rb
sidekiq-unique-jobs-4.0.11 lib/sidekiq_unique_jobs/server/middleware.rb