Class: ConcurrentDownloader::Processor

Inherits:
Object
  • Object
show all
Defined in:
lib/concurrent_downloader/processor.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.process_queue!(queue, options = {}, &block) ⇒ Object



5
6
7
# File 'lib/concurrent_downloader/processor.rb', line 5

def process_queue!(queue, options={}, &block)
  new.process_queue!(queue, options, &block)
end

Instance Method Details

#process_queue!(queue, options = {}, &block) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/concurrent_downloader/processor.rb', line 10

def process_queue!(queue, options={}, &block)
  @queue                = queue || []
  @host                 = options[:host]

  @error_limit          = options[:error_limit] || 0
  @concurrent_downloads = options[:concurrent_downloads] || 1
  @connect_timeout      = options[:connect_timeout] || 5
  @inactivity_timeout   = options[:inactivity_timeout] || 10

  @error_count          = 0
  @error_limit_passed   = false
  @response_block       = block

  EM.run do
    @concurrent_downloads.times do |downloader_id|
      recursive_download(downloader_id)
    end
  end
end