28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/socketlabs/injectionapi/core/retryhandler.rb', line 28
def send(request)
if @retry_settings.maximum_number_of_retries == 0
response = @http_client.send_request(request)
response
end
attempts = 0
loop do
wait_interval = @retry_settings.get_next_wait_interval(attempts)
begin
response = @http_client.send_request(request)
if (@error_codes.include? response.status_code.to_i) && (attempts < @retry_settings.maximum_number_of_retries)
attempts += 1
else
response
end
rescue Timeout::Error => exception
attempts += 1
if attempts > @retry_settings.maximum_number_of_retries
raise exception
end
sleep(wait_interval)
rescue Exception => exception
raise exception
end
end
end
|