class Eye::Application

Attributes

groups[R]
name[R]

Public Class Methods

new(name, config = {}) click to toggle source
# File lib/eye/application.rb, line 5
def initialize(name, config = {})
  @groups = Eye::Utils::AliveArray.new
  @name = name
  @config = config
  debug 'created'
end

Public Instance Methods

add_group(group) click to toggle source
# File lib/eye/application.rb, line 20
def add_group(group)
  @groups << group
end
alive?() click to toggle source
# File lib/eye/application.rb, line 57
def alive?
  true # emulate celluloid actor method
end
debug_data() click to toggle source
# File lib/eye/application.rb, line 46
def debug_data
end
full_name() click to toggle source
# File lib/eye/application.rb, line 16
def full_name
  @name
end
logger_tag() click to toggle source
# File lib/eye/application.rb, line 12
def logger_tag
  full_name
end
processes() click to toggle source
# File lib/eye/application.rb, line 67
def processes
  out = []
  @groups.each{|gr| out += gr.processes.to_a }
  Eye::Utils::AliveArray.new(out)
end
resort_groups() click to toggle source

sort processes in name order

# File lib/eye/application.rb, line 25
def resort_groups
  @groups = @groups.sort { |a, b| a.hidden ? 1 : (b.hidden ? -1 : (a.name <=> b.name)) }
end
send_command(command, *args) click to toggle source
# File lib/eye/application.rb, line 49
def send_command(command, *args)
  info "send_command #{command}"

  @groups.each do |group|
    group.send_command(command, *args)
  end
end
status_data(debug = false) click to toggle source
# File lib/eye/application.rb, line 29
def status_data(debug = false)
  h = { name: @name, type: :application, subtree: @groups.map{|gr| gr.status_data(debug) }}
  h.merge!(debug: debug_data) if debug
  h
end
status_data_short() click to toggle source
# File lib/eye/application.rb, line 35
def status_data_short
  h = Hash.new
  @groups.each do |c|
    c.processes.each do |p|
      h[p.state] ||= 0
      h[p.state] += 1
    end
  end
  { name: @name, type: :application, states: h}
end
sub_object?(obj) click to toggle source
# File lib/eye/application.rb, line 61
def sub_object?(obj)
  res = @groups.include?(obj)
  res = @groups.any?{|gr| gr.sub_object?(obj)} if !res
  res
end