Sha256: 57d9aa44ff4d2b0a939db82076d9485e290abfa0bd43c98f5dc452999b3b8e13

Contents?: true

Size: 996 Bytes

Versions: 10

Compression:

Stored size: 996 Bytes

Contents

if defined?(Resque::Worker)
  Resque.send(:extend, Resque::Additions)
  Resque::Worker.send(:include, Resque::DynamicQueues)
  Resque::Worker.send(:include, Resque::SilenceDone) if ZuoraConnect.configuration.silencer_resque_finish == true
  Resque::Job.send(:include, Resque::SelfLookup)
end

if defined?(Resque::Job) && defined?(Prometheus)
  module ResquePrometheusExtensions
    EXPORTER = Prometheus::ResqueExporter.new
    def perform
      super
      EXPORTER.export
    end
  end

  class Resque::Job
    prepend ResquePrometheusExtensions
  end
end

Resque.module_eval do
  # Returns a hash, mapping queue names to queue sizes
  def queue_sizes
    paused_queues = Resque.redis.zrange("PauseQueue", 0, -1).map! {|key| key.split("__")[0]}
    queue_names = queues.delete_if{|name| paused_queues.include?(name.split("_")[0])}

    sizes = redis.pipelined do
      queue_names.each do |name|
        redis.llen("queue:#{name}")
      end
    end

    Hash[queue_names.zip(sizes)]
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
zuora_connect-3.0.0l config/initializers/resque.rb
zuora_connect-3.0.0k config/initializers/resque.rb
zuora_connect-3.0.0.pre.j config/initializers/resque.rb
zuora_connect-3.0.0.pre.i config/initializers/resque.rb
zuora_connect-3.0.0.pre.h config/initializers/resque.rb
zuora_connect-3.0.0.pre.g config/initializers/resque.rb
zuora_connect-3.0.0.pre.f config/initializers/resque.rb
zuora_connect-3.0.0.pre.e config/initializers/resque.rb
zuora_connect-3.0.0.pre.d config/initializers/resque.rb
zuora_connect-3.0.0.pre.c config/initializers/resque.rb