Module: HttpStatusChecker::Base

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

Constant Summary collapse

THREAD_LIMIT =
5.freeze
REDIRECT_MAX =
5.freeze
RETRY_MAX =
3.freeze

Instance Method Summary collapse

Instance Method Details

#check(urls, wait_sec = 1) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/http_status_checker/base.rb', line 7

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, wait_sec)
      sleep(wait_sec) if urls.count != idx
    end
  end

  return results
end