Class: Sumologic::Metadata::CollectorSourceFetcher

Inherits:
Object
  • Object
show all
Defined in:
lib/sumologic/metadata/collector_source_fetcher.rb

Overview

Fetches sources from multiple collectors efficiently Uses Worker utility for concurrent fetching with rate limiting

Instance Method Summary collapse

Constructor Details

#initialize(config: nil) ⇒ CollectorSourceFetcher

Returns a new instance of CollectorSourceFetcher.



10
11
12
13
14
15
16
# File 'lib/sumologic/metadata/collector_source_fetcher.rb', line 10

def initialize(config: nil)
  @config = config || Configuration.new
  @worker = Utils::Worker.new(
    max_threads: @config.max_workers,
    request_delay: @config.request_delay
  )
end

Instance Method Details

#fetch_all(collectors, &block) ⇒ Object

Fetch sources for collectors concurrently Returns array of results with collector info and sources



20
21
22
23
24
25
26
# File 'lib/sumologic/metadata/collector_source_fetcher.rb', line 20

def fetch_all(collectors, &block)
  @worker.execute(collectors, callbacks: {
                    start: ->(workers, total) { log_start(workers, total) },
                    progress: ->(done, total) { log_progress(done, total) },
                    finish: ->(results, duration) { log_finish(results.size, duration) }
                  }, &block)
end