Class: Qswarm::Swarm
Instance Method Summary collapse
- #agent(name, args = nil, &block) ⇒ Object
-
#initialize(config) ⇒ Swarm
constructor
A new instance of Swarm.
- #run ⇒ Object
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 |
#run ⇒ Object
22 23 24 25 26 |
# File 'lib/qswarm/swarm.rb', line 22 def run EventMachine.run do @agents.map { |a| a.run } end end |