Browse Source

respect exponential retry Max (#980)

Nayef Ghattas 8 năm trước cách đây
mục cha
commit
4e73f1fe43
2 tập tin đã thay đổi với 4 bổ sung0 xóa
  1. 1 0
      AUTHORS
  2. 3 0
      policies.go

+ 1 - 0
AUTHORS

@@ -93,3 +93,4 @@ Yasser Abdolmaleki <yasser@yasser.ca>
 Krishnanand Thommandra <devtkrishna@gmail.com>
 Blake Atkinson <me@blakeatkinson.com>
 Dharmendra Parsaila <d4dharmu@gmail.com>
+Nayef Ghattas <nayef.ghattas@datadoghq.com>

+ 3 - 0
policies.go

@@ -187,6 +187,9 @@ func (e *ExponentialBackoffRetryPolicy) napTime(attempts int) time.Duration {
 	napDuration := minFloat * math.Pow(2, float64(attempts-1))
 	// add some jitter
 	napDuration += rand.Float64()*minFloat - (minFloat / 2)
+	if napDuration > float64(e.Max) {
+		return time.Duration(e.Max)
+	}
 	return time.Duration(napDuration)
 }