Module: BugsnagSourcemapUploader

Defined in:
lib/bugsnag_sourcemap_uploader.rb,
lib/bugsnag_sourcemap_uploader/version.rb,
lib/bugsnag_sourcemap_uploader/upload_task.rb

Overview

BugsnagSourcemapUploader is a library to enable parallel sourcemap uploads to Bugsnag.

Defined Under Namespace

Classes: Result, UploadTask

Constant Summary collapse

TASK_TIMEOUT_IN_SECONDS =

Task timeout in seconds

10
VERSION =
'0.1.2'

Class Method Summary collapse

Class Method Details

.upload(assets_metadata:, bugsnag_api_key:, http_options: {}) ⇒ BugsnagSourcemapUploader::Result

Upload sourcemaps to Bugsnag.

Parameters:

  • assets_metadata (Array)

    object Each item in this Array must be an object that responds to ‘#script_path`, `#source_map_path` and `#cdn_url`.

  • bugsnag_api_key (String)

    key The Bugsnag API key.

  • http_options (Hash) (defaults to: {})

    HTTP options Options accepted by HTTParty. Useful to set headers or logging details.

Returns:



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/bugsnag_sourcemap_uploader.rb', line 24

def self.upload(assets_metadata:, bugsnag_api_key:, http_options: {})
  pool = Concurrent::ThreadPoolExecutor.new(
    min_threads: [Concurrent.processor_count, 4].min,
    max_threads: Concurrent.processor_count
  )

  futures = .map do ||
    Concurrent::Promise.execute(executor: pool) do
      UploadTask.new(
        asset_metadata: ,
        bugsnag_api_key: bugsnag_api_key
      ).run(http_options)
    end
  end

  responses = futures.map do |future|
    future.value(TASK_TIMEOUT_IN_SECONDS)
  end

  Result.new(responses)
end