Class: Sidekiq::Stats::Queues

Inherits:
Object
  • Object
show all
Includes:
RedisScanner
Defined in:
lib/sidekiq/api.rb

Instance Method Summary collapse

Methods included from RedisScanner

#sscan

Instance Method Details

#lengthsObject


143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/sidekiq/api.rb', line 143

def lengths
  Sidekiq.redis do |conn|
    queues = sscan(conn, 'queues')

    lengths = conn.pipelined do
      queues.each do |queue|
        conn.llen("queue:#{queue}")
      end
    end

    i = 0
    array_of_arrays = queues.inject({}) do |memo, queue|
      memo[queue] = lengths[i]
      i += 1
      memo
    end.sort_by { |_, size| size }

    Hash[array_of_arrays.reverse]
  end
end