Class: GemChangelogDiff::ConcurrentFetcher
- Inherits:
-
Object
- Object
- GemChangelogDiff::ConcurrentFetcher
- Defined in:
- lib/gem_changelog_diff/concurrent_fetcher.rb
Overview
Thread pool for fetching multiple gems in parallel.
Instance Method Summary collapse
-
#fetch_all(items) {|item| ... } ⇒ Array
Processes items concurrently, returning results in order.
-
#initialize(concurrency: 4) ⇒ ConcurrentFetcher
constructor
A new instance of ConcurrentFetcher.
Constructor Details
#initialize(concurrency: 4) ⇒ ConcurrentFetcher
Returns a new instance of ConcurrentFetcher.
8 9 10 |
# File 'lib/gem_changelog_diff/concurrent_fetcher.rb', line 8 def initialize(concurrency: 4) @concurrency = concurrency end |
Instance Method Details
#fetch_all(items) {|item| ... } ⇒ Array
Processes items concurrently, returning results in order.
17 18 19 20 21 22 23 24 |
# File 'lib/gem_changelog_diff/concurrent_fetcher.rb', line 17 def fetch_all(items, &) return items.map(&) if @concurrency <= 1 total_timeout = GemChangelogDiff.configuration.total_timeout Timeout.timeout(total_timeout, NetworkError, "Total timeout of #{total_timeout}s exceeded") do run_workers(items, &) end end |