Class: NDD::UrlChecker::ParallelUrlChecker

Inherits:
AbstractUrlChecker show all
Defined in:
lib/ndd/url_checker/parallel_url_checker.rb

Overview

Wraps an instance of ThreadedUrlChecker or ForkedUrlChecker depending of the underlying Ruby implementation.

Author:

  • David DIDIER

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(delegate_checker: nil, parallelism: 10) ⇒ ParallelUrlChecker

Create a new instance.

Parameters:



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/ndd/url_checker/parallel_url_checker.rb', line 21

def initialize(delegate_checker: nil, parallelism: 10)
  @logger = Logging.logger[self]

  @logger.debug "Ruby engine is #{RUBY_ENGINE}"
  if RUBY_ENGINE == 'jruby'
    @logger.info 'Creating a threaded URL checker'
    parallel_checker = ThreadedUrlChecker.new(delegate_checker: delegate_checker, parallelism: parallelism)
  else
    @logger.info 'Creating a forked URL checker'
    parallel_checker = ForkedUrlChecker.new(delegate_checker: delegate_checker, parallelism: parallelism)
  end

  @delegate = parallel_checker
end

Instance Attribute Details

#delegate#check (readonly)

the delegate URL checker.

Returns:

  • (#check)

    the current value of delegate



14
15
16
# File 'lib/ndd/url_checker/parallel_url_checker.rb', line 14

def delegate
  @delegate
end

Instance Method Details

#check(*urls) ⇒ NDD::UrlChecker::Status+

Checks that the given URLs are valid.

Parameters:

  • urls (String, Array<String>)

    the URLs to check

Returns:



40
41
42
# File 'lib/ndd/url_checker/parallel_url_checker.rb', line 40

def check(*urls)
  @delegate.check(*urls)
end