1
0
Fork 0
mirror of https://github.com/fog/fog-aws.git synced 2022-11-09 13:50:52 -05:00

DEV-161796 Add jitter to exponential backoff.

This commit is contained in:
Michael Sawyer 2017-10-25 11:52:54 -07:00
parent e36bccc208
commit e562fab0f9

View file

@ -560,7 +560,16 @@ module Fog
Fog::Compute::AWS::NotFound.slurp(error, match[:message])
when 'RequestLimitExceeded'
if retries < max_retries
sleep (2.0 ** (1.0 + retries) * 100) / 1000.0
jitter = rand(100)
waiting = true
start_time = Time.now
wait_time = ((2.0 ** (1.0 + retries) * 100) + jitter) / 1000.0
puts "Waiting #{wait_time} seconds to retry."
while waiting
if Time.now - start_time >= wait_time
waiting = false
end
end
retries += 1
retry
else