class Centurion::DockerServerGroup

Attributes

hosts[R]

Public Class Methods

new(hosts, docker_path, tls_params = {}) click to toggle source
# 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

Public Instance Methods

each(&block) click to toggle source
# 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) click to toggle source
# 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