mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Rename 'at' to 'beat' since it represents the time of last heartbeat, fix spec.
This commit is contained in:
parent
ba8c8a57b9
commit
d233b4f650
4 changed files with 10 additions and 9 deletions
|
@ -437,7 +437,7 @@ module Sidekiq
|
|||
# 'concurrency' => 25,
|
||||
# 'queues' => ['default', 'low'],
|
||||
# 'busy' => 10,
|
||||
# 'at' => <last heartbeat>,
|
||||
# 'beat' => <last heartbeat>,
|
||||
# }
|
||||
|
||||
class ProcessSet
|
||||
|
@ -449,10 +449,10 @@ module Sidekiq
|
|||
to_prune = []
|
||||
Sidekiq.redis do |conn|
|
||||
procs.sort.each do |key|
|
||||
info, busy, at_s = conn.hmget(key, 'info', 'busy', 'at')
|
||||
info, busy, at_s = conn.hmget(key, 'info', 'busy', 'beat')
|
||||
(to_prune << key; next) if info.nil?
|
||||
hash = Sidekiq.load_json(info)
|
||||
yield hash.merge('busy' => busy.to_i, 'at' => at_s.to_f)
|
||||
yield hash.merge('busy' => busy.to_i, 'beat' => at_s.to_f)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -148,7 +148,7 @@ module Sidekiq
|
|||
watchdog('heartbeat') do
|
||||
Sidekiq.redis do |conn|
|
||||
conn.multi do
|
||||
conn.hmset(key, 'busy', @busy.size, 'at', Time.now.to_f)
|
||||
conn.hmset(key, 'busy', @busy.size, 'beat', Time.now.to_f)
|
||||
conn.expire(key, 60)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -348,7 +348,7 @@ class TestApi < Sidekiq::Test
|
|||
Sidekiq.redis do |conn|
|
||||
conn.multi do
|
||||
conn.sadd('processes', odata['key'])
|
||||
conn.hmset(odata['key'], 'info', Sidekiq.dump_json(odata), 'busy', 10, 'at', time)
|
||||
conn.hmset(odata['key'], 'info', Sidekiq.dump_json(odata), 'busy', 10, 'beat', time)
|
||||
conn.sadd('processes', 'fake:pid')
|
||||
end
|
||||
end
|
||||
|
@ -356,7 +356,7 @@ class TestApi < Sidekiq::Test
|
|||
ps = Sidekiq::ProcessSet.new.to_a
|
||||
assert_equal 1, ps.size
|
||||
data = ps.first
|
||||
assert_equal odata.merge('busy' => 10, 'at' => time), data
|
||||
assert_equal odata.merge('busy' => 10, 'beat' => time), data
|
||||
end
|
||||
|
||||
it 'can enumerate workers' do
|
||||
|
|
|
@ -261,11 +261,12 @@ class TestWeb < Sidekiq::Test
|
|||
assert last_response.body.include?( "args\">"<a>hello</a>"<" )
|
||||
assert !last_response.body.include?( "args\"><a>hello</a><" )
|
||||
|
||||
|
||||
# on /workers page
|
||||
Sidekiq.redis do |conn|
|
||||
conn.sadd('processes', 'foo:1234')
|
||||
identity = 'foo:1234:workers'
|
||||
pro = 'foo:1234'
|
||||
conn.sadd('processes', pro)
|
||||
conn.hmset(pro, 'info', Sidekiq.dump_json('started_at' => Time.now.to_f), 'busy', 1, 'beat', Time.now.to_f)
|
||||
identity = "#{pro}:workers"
|
||||
hash = {:queue => 'critical', :payload => { 'class' => "FailWorker", 'args' => ["<a>hello</a>"] }, :run_at => Time.now.to_i }
|
||||
conn.hmset(identity, 100001, Sidekiq.dump_json(hash))
|
||||
conn.incr('busy')
|
||||
|
|
Loading…
Reference in a new issue