Sha256: 24a2ae5187182093690e66001aa787d79660f427867a8c5c0c02dda59f78629a

Contents?: true

Size: 789 Bytes

Versions: 7

Compression:

Stored size: 789 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

      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

7 entries across 7 versions & 1 rubygems

Version Path
sidekiq-unique-jobs-5.0.2 lib/sidekiq_unique_jobs/server/middleware.rb
sidekiq-unique-jobs-5.0.1 lib/sidekiq_unique_jobs/server/middleware.rb
sidekiq-unique-jobs-5.0.0 lib/sidekiq_unique_jobs/server/middleware.rb
sidekiq-unique-jobs-4.0.18 lib/sidekiq_unique_jobs/server/middleware.rb
sidekiq-unique-jobs-4.0.17 lib/sidekiq_unique_jobs/server/middleware.rb
sidekiq-unique-jobs-4.0.16 lib/sidekiq_unique_jobs/server/middleware.rb
sidekiq-unique-jobs-4.0.15 lib/sidekiq_unique_jobs/server/middleware.rb