Skip to content

Commit f0582a2

Browse files
EdgeJJohn Edge
authored andcommitted
Run multiple node diffs in parallel
1 parent 89d93f1 commit f0582a2

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

lib/octocatalog-diff/cli.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
require_relative 'version'
1212

1313
require 'logger'
14+
require 'parallel'
1415
require 'socket'
1516

1617
module OctocatalogDiff
@@ -118,7 +119,9 @@ def self.cli(argv = ARGV, logger = Logger.new(STDERR), opts = {})
118119
# Compile catalogs and do catalog-diff
119120
node_set = options.delete(:node)
120121
all_diffs = []
121-
node_set.each do |node|
122+
123+
# run multiple node diffs in parallel
124+
Parallel.map(node_set) do |node|
122125
options[:node] = node
123126
catalog_diff = OctocatalogDiff::API::V1.catalog_diff(options.merge(logger: logger))
124127
diffs = catalog_diff.diffs
@@ -131,8 +134,8 @@ def self.cli(argv = ARGV, logger = Logger.new(STDERR), opts = {})
131134
all_diffs << diffs
132135
end
133136

134-
# Return the resulting diff object if requested (generally for testing) or otherwise return exit code
135-
return catalog_diff if opts[:INTEGRATION]
137+
# Return the resulting diff objects if requested (generally for testing) or otherwise return exit code
138+
return all_diffs if opts[:INTEGRATION]
136139
all_diffs.any? ? EXITCODE_SUCCESS_WITH_DIFFS : EXITCODE_SUCCESS_NO_DIFFS
137140
end
138141

octocatalog-diff.gemspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ EOF
2727
s.add_runtime_dependency 'diffy', '>= 3.1.0'
2828
s.add_runtime_dependency 'httparty', '>= 0.11.0'
2929
s.add_runtime_dependency 'hashdiff', '>= 0.3.0'
30+
s.add_runtime_dependency 'parallel'
3031
s.add_runtime_dependency 'rugged', '>= 0.25.0b2'
3132

3233
s.add_development_dependency 'rspec', '~> 3.4.0'

0 commit comments

Comments
 (0)