1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

Add size back.

This commit is contained in:
Brandon Hilkert 2012-12-04 12:13:47 -05:00
parent 005c868d2c
commit 7719effdee
2 changed files with 19 additions and 0 deletions

View file

@ -23,4 +23,14 @@ module Sidekiq
inject(0) {|memo, val| memo + val }
results
end
def size(*queues)
return info[:backlog] if queues.empty?
Sidekiq.redis { |conn|
conn.multi {
queues.map { |q| conn.llen("queue:#{q}") }
}
}.inject(0) { |memo, count| memo += count }
end
end

View file

@ -92,6 +92,15 @@ class TestStats < MiniTest::Unit::TestCase
end
end
describe "size" do
it "returns size of queues" do
assert_equal 0, Sidekiq.size("foox")
assert_equal 1, Sidekiq.size(:foo)
assert_equal 1, Sidekiq.size("foo")
assert_equal 4, Sidekiq.size("foo", "bar")
assert_equal 6, Sidekiq.size
end
end
end
end