Class: Autoscale::Agent::WorkerDispatchers

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/autoscale/agent/worker_dispatchers.rb

Constant Summary collapse

DISPATCH_INTERVAL =
15

Instance Method Summary collapse

Constructor Details

#initializeWorkerDispatchers

Returns a new instance of WorkerDispatchers.



8
9
10
# File 'lib/autoscale/agent/worker_dispatchers.rb', line 8

def initialize
  @dispatchers = []
end

Instance Method Details

#<<(dispatcher) ⇒ Object



16
17
18
# File 'lib/autoscale/agent/worker_dispatchers.rb', line 16

def <<(dispatcher)
  @dispatchers << dispatcher
end

#dispatchObject



20
21
22
23
24
25
26
# File 'lib/autoscale/agent/worker_dispatchers.rb', line 20

def dispatch
  each do |dispatcher|
    dispatcher.dispatch
  rescue => err
    puts "Autoscale::Agent/WorkerDispatcher: #{err}\n#{err.backtrace.join("\n")}"
  end
end

#each(&block) ⇒ Object



12
13
14
# File 'lib/autoscale/agent/worker_dispatchers.rb', line 12

def each(&block)
  @dispatchers.each(&block)
end

#runObject



28
29
30
# File 'lib/autoscale/agent/worker_dispatchers.rb', line 28

def run
  Util.loop_with_interval(DISPATCH_INTERVAL) { dispatch }
end