Class: SSHKit::Runner::Group

Inherits:
Sequential show all
Defined in:
lib/sshkit/runners/group.rb

Instance Attribute Summary collapse

Attributes inherited from Sequential

#wait_interval

Attributes inherited from Abstract

#block, #hosts, #options

Instance Method Summary collapse

Constructor Details

#initialize(hosts, options = nil, &block) ⇒ Group

Returns a new instance of Group.



8
9
10
11
# File 'lib/sshkit/runners/group.rb', line 8

def initialize(hosts, options = nil, &block)
  super(hosts, options, &block)
  @group_size = @options[:limit] || 2
end

Instance Attribute Details

#group_sizeObject

Returns the value of attribute group_size.



6
7
8
# File 'lib/sshkit/runners/group.rb', line 6

def group_size
  @group_size
end

Instance Method Details

#executeObject



13
14
15
16
17
18
# File 'lib/sshkit/runners/group.rb', line 13

def execute
  hosts.each_slice(group_size).collect do |group_hosts|
    Parallel.new(group_hosts, &block).execute
    sleep wait_interval
  end.flatten
end