Class: Qswarm::Swarm

Inherits:
Object
  • Object
show all
Includes:
DSL
Defined in:
lib/qswarm/swarm.rb

Instance Method Summary collapse

Methods included from DSL

#dsl_call, #dsl_load, included

Constructor Details

#initialize(config) ⇒ Swarm

Returns a new instance of Swarm.



10
11
12
13
14
15
# File 'lib/qswarm/swarm.rb', line 10

def initialize(config)
  @agents = []
  $fqdn = Socket.gethostbyname(Socket.gethostname).first

  dsl_load(config)
end

Instance Method Details

#agent(name, args = nil, &block) ⇒ Object



17
18
19
20
# File 'lib/qswarm/swarm.rb', line 17

def agent(name, args = nil, &block)
  Qswarm.logger.info "Registering agent: #{name.inspect}"
  @agents << Qswarm::Agent.new(self, name, args, &block)
end

#runObject



22
23
24
25
26
# File 'lib/qswarm/swarm.rb', line 22

def run
  EventMachine.run do
    @agents.map { |a| a.run }
  end
end