class Stats

Public Class Methods

new(stats) click to toggle source
# File lib/stats.rb, line 87
def initialize(stats)
  @stats = stats
end

Public Instance Methods

booting?() click to toggle source
# File lib/stats.rb, line 116
def booting?
  workers.all?(&:booting?)
end
load() click to toggle source
# File lib/stats.rb, line 154
def load
  running_threads/total_threads.to_f*100
end
max_threads() click to toggle source
# File lib/stats.rb, line 132
def max_threads
  workers.reduce(0) { |total, wstats| total + wstats.max_threads }
end
phase() click to toggle source
# File lib/stats.rb, line 150
def phase
  @stats['phase']
end
pid() click to toggle source
# File lib/stats.rb, line 99
def pid
  @stats['pid']
end
pid=(pid) click to toggle source
# File lib/stats.rb, line 95
def pid=(pid)
  @stats['pid'] = pid
end
pool_capacity() click to toggle source
# File lib/stats.rb, line 146
def pool_capacity
  @stats['pool_capacity'] || 0
end
requests_count() click to toggle source
# File lib/stats.rb, line 136
def requests_count
  workers_with_requests_count = workers.select(&:requests_count)
  return if workers_with_requests_count.none?
  workers_with_requests_count.reduce(0) { |total, wstats| total + wstats.requests_count }
end
running() click to toggle source
# File lib/stats.rb, line 142
def running
  @stats['running'] || 0
end
running_threads() click to toggle source
# File lib/stats.rb, line 124
def running_threads
  workers.reduce(0) { |total, wstats| total + wstats.running_threads }
end
spawned_threads() click to toggle source
# File lib/stats.rb, line 128
def spawned_threads
  workers.reduce(0) { |total, wstats| total + wstats.spawned_threads }
end
state_file_path() click to toggle source
# File lib/stats.rb, line 107
def state_file_path
  @stats['state_file_path']
end
state_file_path=(state_file_path) click to toggle source
# File lib/stats.rb, line 103
def state_file_path=(state_file_path)
  @stats['state_file_path'] = state_file_path
end
total_threads() click to toggle source
# File lib/stats.rb, line 120
def total_threads
  workers.reduce(0) { |total, wstats| total + wstats.max_threads }
end
uptime() click to toggle source
# File lib/stats.rb, line 111
def uptime
  return 0 unless @stats.key?('started_at')
  (Time.now - Time.parse(@stats['started_at'])).to_i
end
workers() click to toggle source
# File lib/stats.rb, line 91
def workers
  @workers ||= (@stats['worker_status'] || [@stats]).map { |wstats| Worker.new(wstats) }
end