Class: Nonnative::Pool

Inherits:
Object
  • Object
show all
Defined in:
lib/nonnative/pool.rb

Instance Method Summary collapse

Constructor Details

#initialize(configuration) ⇒ Pool

Returns a new instance of Pool.



5
6
7
# File 'lib/nonnative/pool.rb', line 5

def initialize(configuration)
  @configuration = configuration
end

Instance Method Details

#process_by_name(name) ⇒ Object



19
20
21
22
# File 'lib/nonnative/pool.rb', line 19

def process_by_name(name)
  index = configuration.processes.find_index { |s| s.name == name }
  processes[index].first
end

#server_by_name(name) ⇒ Object



24
25
26
27
# File 'lib/nonnative/pool.rb', line 24

def server_by_name(name)
  index = configuration.servers.find_index { |s| s.name == name }
  servers[index].first
end

#service_by_name(name) ⇒ Object



29
30
31
32
# File 'lib/nonnative/pool.rb', line 29

def service_by_name(name)
  index = configuration.services.find_index { |s| s.name == name }
  services[index]
end

#start(&block) ⇒ Object



9
10
11
12
# File 'lib/nonnative/pool.rb', line 9

def start(&block)
  services.each(&:start)
  [servers, processes].each { |t| process(t, :start, :open?, &block) }
end

#stop(&block) ⇒ Object



14
15
16
17
# File 'lib/nonnative/pool.rb', line 14

def stop(&block)
  [processes, servers].each { |t| process(t, :stop, :closed?, &block) }
  services.each(&:stop)
end