Class: Invoker::IPC::Message::ListResponse

Inherits:
Base
  • Object
show all
Includes:
Serialization
Defined in:
lib/invoker/ipc/message/list_response.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Serialization

#as_json, #attributes, #encoded_message, #eql?, included, #message_attributes, #to_json

Methods inherited from Base

#command_handler_klass, #message_type

Constructor Details

#initialize(options) ⇒ ListResponse

Returns a new instance of ListResponse.



7
8
9
10
11
12
13
# File 'lib/invoker/ipc/message/list_response.rb', line 7

def initialize(options)
  self.processes = []
  process_array = options[:processes] || options['processes']
  process_array.each do |process_hash|
    processes << Process.new(process_hash)
  end
end

Class Method Details

.from_workers(workers) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/invoker/ipc/message/list_response.rb', line 15

def self.from_workers(workers)
  process_array = []
  Invoker.config.processes.each do |process|
    worker_attrs = {
      shell_command: process.cmd,
      process_name: process.label,
      dir: process.dir,
      port: process.port
    }
    if worker = workers[process.label]
      worker_attrs.update(pid: worker.pid)
    end
    process_array << worker_attrs
  end

  new(processes: process_array)
end