Created
April 2, 2015 03:14
-
-
Save rickhull/26c0a0523d87cf0b62df to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
num_threads.times { | |
threads << Thread.new { | |
while !queue.empty? | |
# pop the queue | |
verb, path, query, orig_rc, orig_latency = *queue.deq | |
# issue HTTP request | |
# get HTTP response | |
# categorize response into success, failure, timeout, questionable | |
begin | |
rc, body, latency = Timeout.timeout(timeout) { | |
perform_http(verb, host_str, path, query) | |
} | |
rescue Timeout::Error | |
results[:timeout] << [verb, path, nil, timeout * 1000] | |
end | |
if rc != orig_rc | |
results[:failure] << [verb, path, rc, latency, orig_rc] | |
elsif latency > latency_threshold | |
results[:questionable] << [verb, path, rc, latency, body] | |
else | |
results[:success] << [verb, path, rc, latency] | |
end | |
end | |
} | |
} | |
# wait for all threads to complete | |
threads.each { |thr| thr.join } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment