mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
refactor stat method
This commit is contained in:
parent
a2c7541518
commit
465c5c610c
1 changed files with 6 additions and 10 deletions
|
@ -65,13 +65,12 @@ module Sidekiq
|
|||
end
|
||||
}
|
||||
|
||||
|
||||
default_queue_latency = if (entry = pipe1_res[6].first)
|
||||
job = begin
|
||||
Sidekiq.load_json(entry)
|
||||
rescue
|
||||
{}
|
||||
end
|
||||
Sidekiq.load_json(entry)
|
||||
rescue
|
||||
{}
|
||||
end
|
||||
now = Time.now.to_f
|
||||
thence = job["enqueued_at"] || now
|
||||
now - thence
|
||||
|
@ -138,11 +137,8 @@ module Sidekiq
|
|||
private
|
||||
|
||||
def stat(s)
|
||||
if (s == :enqueued || s == :workers_size) &&
|
||||
@stats.present? && @stats[s].nil?
|
||||
fetch_stats_slow!
|
||||
end
|
||||
@stats[s]
|
||||
fetch_stats_slow! if @stats[s].nil?
|
||||
@stats[s] || raise(ArgumentError, "Unknown stat #{s}")
|
||||
end
|
||||
|
||||
class Queues
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue