Class: Ndo::MultiHost
- Inherits:
-
Object
- Object
- Ndo::MultiHost
- Includes:
- Procrastinate
- Defined in:
- lib/ndo/multi_host.rb
Overview
A class to execute a command on a list of hosts in parallel; allows access to results and is thus a) multi threaded and b) Ruby 1.9.2 only.
Instance Attribute Summary collapse
-
#hosts ⇒ Object
readonly
Returns the value of attribute hosts.
Instance Method Summary collapse
-
#initialize(hosts) ⇒ MultiHost
constructor
A new instance of MultiHost.
-
#run(command) ⇒ Object
Runs the command on all hosts.
- #run_for_host(command, host) ⇒ Object
Constructor Details
#initialize(hosts) ⇒ MultiHost
Returns a new instance of MultiHost.
13 14 15 |
# File 'lib/ndo/multi_host.rb', line 13 def initialize(hosts) @hosts = hosts end |
Instance Attribute Details
#hosts ⇒ Object (readonly)
Returns the value of attribute hosts.
11 12 13 |
# File 'lib/ndo/multi_host.rb', line 11 def hosts @hosts end |
Instance Method Details
#run(command) ⇒ Object
Runs the command on all hosts. Returns a result collection.
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/ndo/multi_host.rb', line 19 def run(command) proxy = Procrastinate.proxy(self) hosts.inject(Hash.new) do |hash, host_name| hash[host_name] = Ndo::Result.new( host_name, proxy.run_for_host(command, host_name)) hash end end |