Class: Centurion::DockerServerGroup
- Inherits:
-
Object
- Object
- Centurion::DockerServerGroup
- Includes:
- Logging, Enumerable
- Defined in:
- lib/centurion/docker_server_group.rb
Instance Attribute Summary collapse
-
#hosts ⇒ Object
readonly
Returns the value of attribute hosts.
Instance Method Summary collapse
- #each(&block) ⇒ Object
- #each_in_parallel(&block) ⇒ Object
-
#initialize(hosts, docker_path, tls_params = {}) ⇒ DockerServerGroup
constructor
A new instance of DockerServerGroup.
Methods included from Logging
Constructor Details
#initialize(hosts, docker_path, tls_params = {}) ⇒ DockerServerGroup
Returns a new instance of DockerServerGroup.
12 13 14 15 16 17 |
# File 'lib/centurion/docker_server_group.rb', line 12 def initialize(hosts, docker_path, tls_params = {}) raise ArgumentError.new('Bad Host list!') if hosts.nil? || hosts.empty? @hosts = hosts.map do |hostname| Centurion::DockerServer.new(hostname, docker_path, tls_params) end end |
Instance Attribute Details
#hosts ⇒ Object (readonly)
Returns the value of attribute hosts.
10 11 12 |
# File 'lib/centurion/docker_server_group.rb', line 10 def hosts @hosts end |
Instance Method Details
#each(&block) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/centurion/docker_server_group.rb', line 19 def each(&block) @hosts.each do |host| info "----- Connecting to Docker on #{host.hostname} -----" block.call(host) end end |
#each_in_parallel(&block) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/centurion/docker_server_group.rb', line 26 def each_in_parallel(&block) threads = @hosts.map do |host| Thread.new { block.call(host) } end threads.each { |t| t.join } end |