Module: Polytrix::Command::RunAction
Overview
Common module to execute a Polytrix action such as create, converge, etc.
Instance Method Summary collapse
-
#run_action(action, scenarios, *args) ⇒ Object
Run an instance action (create, converge, setup, verify, destroy) on a collection of scenarios.
Instance Method Details
#run_action(action, scenarios, *args) ⇒ Object
Run an instance action (create, converge, setup, verify, destroy) on a collection of scenarios. The instance actions will take place in a seperate thread of execution which may or may not be running concurrently.
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
# File 'lib/polytrix/command.rb', line 187 def run_action(action, scenarios, *args) concurrency = 1 if [:concurrency] concurrency = [:concurrency] || scenarios.size concurrency = scenarios.size if concurrency > scenarios.size end queue = Queue.new scenarios.each { |i| queue << i } concurrency.times { queue << nil } threads = [] concurrency.times do threads << Thread.new do while (instance = queue.pop) instance.public_send(action, *args) end end end threads.map { |i| i.join } end |