Last active
December 24, 2015 02:59
-
-
Save ncdc/6734300 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'parallel' | |
def with_gear_rotation(options={}, &block) | |
gears = [1,2,3] | |
parallel_output = Parallel.map(gears, :in_threads => 3) do |target| | |
rotate_and_yield(target, options, &block) | |
end | |
end | |
def rotate_and_yield(target, options, &block) | |
out = [] | |
out << "Rotate out #{target}" | |
out << yield(target, options) | |
out << "Rotate in #{target}" | |
out | |
end | |
def restart(options={}) | |
with_gear_rotation do |target, options| | |
restart_gear(target, options) | |
end | |
end | |
def restart_gear(target, options) | |
"restart_gear #{target}" | |
end | |
output = restart | |
output.each do |o| | |
puts o.join("\n") | |
puts "" | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rotate out 1 | |
restart_gear 1 | |
Rotate in 1 | |
Rotate out 2 | |
restart_gear 2 | |
Rotate in 2 | |
Rotate out 3 | |
restart_gear 3 | |
Rotate in 3 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment