Class: Geary::Manager

Inherits:
Object
  • Object
show all
Includes:
Celluloid
Defined in:
lib/geary/manager.rb

Constant Summary collapse

UnexpectedRestart =
Class.new(Error)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Manager

Returns a new instance of Manager.



15
16
17
18
19
20
21
# File 'lib/geary/manager.rb', line 15

def initialize(options = {})
  @configuration = options.fetch(:configuration)
  @performer_type = options.fetch(:performer_type, Performer)
  @performers = []
  @crashes = []
  @server_addresses_by_performer = {}
end

Instance Attribute Details

#configurationObject (readonly)

Returns the value of attribute configuration.



11
12
13
# File 'lib/geary/manager.rb', line 11

def configuration
  @configuration
end

#performersObject (readonly)

Returns the value of attribute performers.



11
12
13
# File 'lib/geary/manager.rb', line 11

def performers
  @performers
end

Instance Method Details

#startObject



23
24
25
26
27
28
29
30
31
# File 'lib/geary/manager.rb', line 23

def start
  async.monitor_crashes

  configuration.server_addresses.each do |server_address|
    configuration.concurrency.times do
      start_performer(server_address)
    end
  end
end

#stopObject



33
34
35
36
37
# File 'lib/geary/manager.rb', line 33

def stop
  @performers.select(&:alive?).each(&:terminate)

  after(0) { signal(:done) }
end