Class: Eye::Group

Inherits:
Object show all
Includes:
Celluloid, Call, Chain, Data, Process::Scheduler
Defined in:
lib/eye/group.rb

Defined Under Namespace

Modules: Call, Chain, Data

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Data

#debug_data, #status_data, #status_data_short

Methods included from Call

#break_chain, #delete, #monitor, #restart, #send_call, #signal, #start, #stop, #unmonitor, #update_config, #user_command

Methods included from Process::Scheduler

#ensure_scheduler_process, #equal_action_call?, #filter_call, #internal_schedule, #schedule, #scheduler_add, #scheduler_calls, #scheduler_clear_pending_list, #scheduler_commands_list, #scheduler_consume, #scheduler_current_command, #scheduler_history, #scheduler_last_command, #scheduler_last_reason, #scheduler_run, #send_call, #user_schedule

Constructor Details

#initialize(name, config) ⇒ Group

Returns a new instance of Group.



18
19
20
21
22
23
24
# File 'lib/eye/group.rb', line 18

def initialize(name, config)
  @name = name
  @config = config
  @processes = Eye::Utils::AliveArray.new
  @hidden = (name == '__default__')
  debug { 'created' }
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



16
17
18
# File 'lib/eye/group.rb', line 16

def config
  @config
end

#hiddenObject (readonly)

Returns the value of attribute hidden.



16
17
18
# File 'lib/eye/group.rb', line 16

def hidden
  @hidden
end

#nameObject (readonly)

Returns the value of attribute name.



16
17
18
# File 'lib/eye/group.rb', line 16

def name
  @name
end

#processesObject (readonly)

Returns the value of attribute processes.



16
17
18
# File 'lib/eye/group.rb', line 16

def processes
  @processes
end

Instance Method Details

#<=>(other) ⇒ Object

to sort groups



56
57
58
59
60
61
62
63
64
# File 'lib/eye/group.rb', line 56

def <=>(other)
  if hidden
    1
  elsif other.hidden
    -1
  else
    name <=> other.name
  end
end

#add_process(process) ⇒ Object



38
39
40
# File 'lib/eye/group.rb', line 38

def add_process(process)
  @processes << process
end

#app_nameObject



30
31
32
# File 'lib/eye/group.rb', line 30

def app_name
  @config[:application]
end

#clearObject



47
48
49
# File 'lib/eye/group.rb', line 47

def clear
  @processes = Eye::Utils::AliveArray.new
end

#full_nameObject



34
35
36
# File 'lib/eye/group.rb', line 34

def full_name
  @full_name ||= "#{app_name}:#{@name}"
end

#logger_tagObject



26
27
28
# File 'lib/eye/group.rb', line 26

def logger_tag
  full_name
end

#resort_processesObject

sort processes in name order



43
44
45
# File 'lib/eye/group.rb', line 43

def resort_processes
  @processes = @processes.sort_by(&:name)
end

#sub_object?(obj) ⇒ Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/eye/group.rb', line 51

def sub_object?(obj)
  @processes.include?(obj)
end