Class: Sidekiq::Stats::Queues

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

Instance Method Summary collapse

Instance Method Details

#lengthsObject



116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/sidekiq/api.rb', line 116

def lengths
  Sidekiq.redis do |conn|
    queues = conn.smembers('queues'.freeze)

    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