Skip to content

Commit

Permalink
Use parallel gem to do parallelization
Browse files Browse the repository at this point in the history
  • Loading branch information
StefSchenkelaars committed Aug 3, 2021
1 parent 9b3f5a1 commit 049b86c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ PATH
specs:
appsignal-sourcemap (1.0.0.develop)
appsignal (~> 3.0)
parallel (~> 1.0)

GEM
remote: https://rubygems.org/
Expand Down
1 change: 1 addition & 0 deletions appsignal-sourcemap.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
spec.files = Dir["lib/**/*", "README.md"]

spec.add_dependency "appsignal", "~> 3.0"
spec.add_dependency "parallel", "~> 1.0"

spec.add_development_dependency "standard"
end
10 changes: 5 additions & 5 deletions lib/appsignal/sourcemap/supervisor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
module Appsignal
module Sourcemap
class Supervisor
PARALLEL_THREADS = 10

def self.start
new.start
end
Expand All @@ -14,11 +16,9 @@ def start

Appsignal.logger.info("Starting sourcemaps upload")

source_map_paths.map do |source_map_path|
Thread.new do
Uploader.upload(source_map_path)
end
end.each(&:join)
Parallel.each(source_map_paths, in_threads: PARALLEL_THREADS) do |source_map_path|
Uploader.upload(source_map_path)
end

Appsignal.logger.info("Finished sourcemaps upload")
end
Expand Down

0 comments on commit 049b86c

Please sign in to comment.