Merge pull request #1146 from tpam28/master
exponentialBackoff was changed from power function to exponential
This commit is contained in:
commit
50ac642666
@ -8,10 +8,7 @@ import (
|
|||||||
|
|
||||||
type BackoffFunc func(ctx context.Context, req Request, attempts int) (time.Duration, error)
|
type BackoffFunc func(ctx context.Context, req Request, attempts int) (time.Duration, error)
|
||||||
|
|
||||||
// exponential backoff
|
// exponential backoff multiplied by a factor of 0.1 second.
|
||||||
func exponentialBackoff(ctx context.Context, req Request, attempts int) (time.Duration, error) {
|
func exponentialBackoff(ctx context.Context, req Request, attempts int) (time.Duration, error) {
|
||||||
if attempts == 0 {
|
return time.Duration(math.Pow(float64(attempts), math.E)) * time.Millisecond * 100, nil
|
||||||
return time.Duration(0), nil
|
|
||||||
}
|
|
||||||
return time.Duration(math.Pow(10, float64(attempts))) * time.Millisecond, nil
|
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,6 @@ func TestBackoff(t *testing.T) {
|
|||||||
t.Fatalf("Expected greater than %v, got %v", delta, d)
|
t.Fatalf("Expected greater than %v, got %v", delta, d)
|
||||||
}
|
}
|
||||||
|
|
||||||
delta = time.Millisecond * time.Duration(math.Pow(10, float64(i+1)))
|
delta = time.Millisecond * 100 * time.Duration(math.Pow(math.E, float64(i)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user