Class: GemChangelogDiff::ConcurrentFetcher
- Inherits:
-
Object
- Object
- GemChangelogDiff::ConcurrentFetcher
- Defined in:
- lib/gem_changelog_diff/concurrent_fetcher.rb
Instance Method Summary collapse
- #fetch_all(items) ⇒ Object
-
#initialize(concurrency: 4) ⇒ ConcurrentFetcher
constructor
A new instance of ConcurrentFetcher.
Constructor Details
#initialize(concurrency: 4) ⇒ ConcurrentFetcher
Returns a new instance of ConcurrentFetcher.
7 8 9 |
# File 'lib/gem_changelog_diff/concurrent_fetcher.rb', line 7 def initialize(concurrency: 4) @concurrency = concurrency end |
Instance Method Details
#fetch_all(items) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/gem_changelog_diff/concurrent_fetcher.rb', line 11 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 |