Module: HttpStatusChecker::Base

Included in:
HttpStatusChecker
Defined in:
lib/http_status_checker/base.rb

Defined Under Namespace

Classes: InvalidRedirectError, InvalidResponseError

Constant Summary collapse

THREAD_LIMIT =
5.freeze
REDIRECT_MAX =
5.freeze
RETRY_MAX =
1.freeze

Instance Method Summary collapse

Instance Method Details

#check(urls, wait_sec = 1) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/http_status_checker/base.rb', line 10

def check(urls, wait_sec = 1)
  results = []

  host_hash = to_host_hash(urls)
  Parallel.each(host_hash, in_threads: host_hash.keys.count) do |_, urls|
    urls.map.with_index(1) do |url, idx|
      results << get_response(url)
      sleep(wait_sec) if urls.count != idx
    end
  end

  return results
end