2015-05-06 16:14:00 +00:00
|
|
|
package connector
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"math"
|
|
|
|
|
"time"
|
|
|
|
|
)
|
|
|
|
|
|
2016-04-30 23:20:01 +00:00
|
|
|
// AWS Exponential Backoff
|
|
|
|
|
// Wait up to 5 minutes based on the aws exponential backoff algorithm
|
2015-08-17 00:52:10 +00:00
|
|
|
// http://docs.aws.amazon.com/general/latest/gr/api-retries.html
|
|
|
|
|
func handleAwsWaitTimeExp(attempts int) {
|
|
|
|
|
if attempts > 0 {
|
|
|
|
|
waitTime := time.Duration(math.Min(100*math.Pow(2, float64(attempts)), 300000)) * time.Millisecond
|
|
|
|
|
time.Sleep(waitTime)
|
|
|
|
|
}
|
|
|
|
|
}
|