Skip to content

Commit

Permalink
Use parallel gem to do parallelization (#1)
Browse files Browse the repository at this point in the history
* Use parallel gem to do parallelization

* Fix loading of parallel gem
  • Loading branch information
StefSchenkelaars committed Aug 4, 2021
1 parent 9b3f5a1 commit 1005ed3
Show file tree
Hide file tree
Showing 3 changed files with 8 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
11 changes: 6 additions & 5 deletions lib/appsignal/sourcemap/supervisor.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# frozen_string_literal: true

require "parallel"
require "appsignal/sourcemap/uploader"

module Appsignal
module Sourcemap
class Supervisor
PARALLEL_THREADS = 10

def self.start
new.start
end
Expand All @@ -14,11 +17,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 1005ed3

Please sign in to comment.