crusher 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/crusher/http_load_generator.rb +18 -4
- metadata +3 -3
@@ -35,7 +35,24 @@ module Crusher
|
|
35
35
|
}
|
36
36
|
|
37
37
|
start_time = Time.now
|
38
|
-
|
38
|
+
em_request(start_time, uri, block, options)
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def em_request(start_time, uri, block, options, times_to_retry=1)
|
45
|
+
begin
|
46
|
+
http = EM::Protocols::HttpClient.request(options)
|
47
|
+
rescue EventMachine::ConnectionError => error
|
48
|
+
unless times_to_retry > 3
|
49
|
+
@crush_session.logger.warn "retrying for #{times_to_retry} time with error \"#{error}\" failed request #{options.inspect}"
|
50
|
+
em_request(start_time, uri, block, options, (times_to_retry + 1))
|
51
|
+
end
|
52
|
+
@crush_session.logger.error "Failed after 3 tries with error \"#{error}\": #{options.inspect}"
|
53
|
+
raise error
|
54
|
+
end
|
55
|
+
http.callback do |response|
|
39
56
|
duration = ((Time.now - start_time) * 1000).to_i
|
40
57
|
|
41
58
|
response[:headers].each do |header|
|
@@ -45,10 +62,7 @@ module Crusher
|
|
45
62
|
|
46
63
|
block.call(response, duration) if block
|
47
64
|
end
|
48
|
-
|
49
65
|
end
|
50
|
-
|
51
|
-
|
52
66
|
end
|
53
67
|
|
54
68
|
end
|
metadata
CHANGED