module Sidekiq::Queues::Exporter

Constants

HEADERS
MOUNT_PATH
REQUEST_METHOD
REQUEST_VERB
VERSION

Public Class Methods

call(env) click to toggle source
# File lib/sidekiq/queues/exporter.rb, line 41
def call(env)
  return [404, HEADERS, ['Not found']] if env[REQUEST_METHOD] != REQUEST_VERB

  [200, HEADERS, [exports]]
end
exports() click to toggle source
# File lib/sidekiq/queues/exporter.rb, line 16
def exports
  @queues = Sidekiq::Queue.all.map do |queue|
    {
      queue_name: queue.name,
      queue_size: queue.size
    }
  end
  template = ERB.new(File.read(File.expand_path('templates/queues.erb', __dir__)))
  template.result(binding).chomp!
end
registered(app) click to toggle source
# File lib/sidekiq/queues/exporter.rb, line 27
def registered(app)
  app.get(MOUNT_PATH) do
    call(REQUEST_METHOD => REQUEST_VERB)
  end
end
to_app() click to toggle source
# File lib/sidekiq/queues/exporter.rb, line 33
def to_app
  Rack::Builder.app do
    map(MOUNT_PATH) do
      run Sidekiq::Queues::Exporter
    end
  end
end