Class: Autoscale::Agent::WebDispatchers

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

Defined Under Namespace

Classes: AlreadySetError

Constant Summary collapse

DISPATCH_INTERVAL =
15

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeWebDispatchers

Returns a new instance of WebDispatchers.



13
14
15
# File 'lib/autoscale/agent/web_dispatchers.rb', line 13

def initialize
  @dispatchers = []
end

Instance Attribute Details

#queue_timeObject

Returns the value of attribute queue_time.



11
12
13
# File 'lib/autoscale/agent/web_dispatchers.rb', line 11

def queue_time
  @queue_time
end

Instance Method Details

#dispatchObject



30
31
32
33
34
# File 'lib/autoscale/agent/web_dispatchers.rb', line 30

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

#each(&block) ⇒ Object



22
23
24
# File 'lib/autoscale/agent/web_dispatchers.rb', line 22

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

#pruneObject



26
27
28
# File 'lib/autoscale/agent/web_dispatchers.rb', line 26

def prune
  each(&:prune)
end

#runObject



36
37
38
39
40
41
42
43
44
# File 'lib/autoscale/agent/web_dispatchers.rb', line 36

def run
  Thread.new do
    loop do
      prune
      dispatch
      sleep DISPATCH_INTERVAL
    end
  end
end