Sha256: 3e105e5de040a59857d276ee69c9023b934787619af70eb15a2e4106bb079374

Contents?: true

Size: 598 Bytes

Versions: 1

Compression:

Stored size: 598 Bytes

Contents

require 'unique_job/util'

module UniqueJob
  class ClientMiddleware
    include Util

    def initialize(redis_options)
      @history = JobHistory.new(self.class.name, Redis.new(redis_options))
      @context = 'Client'
    end

    def call(worker_str, job, queue, redis_pool, &block)
      if job.has_key?('at')
        # perform_in or perform_at
        yield
      else
        if worker_str.class == String
          worker = worker_str.constantize.new # Sidekiq < 6
        else
          worker = worker_str.new
        end
        perform(worker, job, &block)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
unique_job-0.5.0 lib/unique_job/client_middleware.rb