kinesis-consumer/awsbackoff.go

17 lines
400 B
Go
Raw Normal View History

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
// 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)
}
}