Class: Sidekiq::Stats::Queues

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

Instance Method Summary collapse

Instance Method Details

#lengthsObject


133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/sidekiq/api.rb', line 133

def lengths
  Sidekiq.redis do |conn|
    queues = conn.sscan_each("queues").to_a

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

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

    Hash[array_of_arrays.reverse]
  end
end