@@ -21,6 +21,27 @@ const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
2121var seededRand * rand.Rand = rand .New (
2222 rand .NewSource (time .Now ().UnixNano ()))
2323
24+ // getExponentialBackOff returns a preconfigured exponential backoff instance
25+ //nolint:unused
26+ func getExponentialBackOff (elapsedMinutes time.Duration ) * backoff.ExponentialBackOff {
27+ var (
28+ initialInterval = 500 * time .Millisecond
29+ randomizationFactor = 0.5
30+ multiplier = 2.0
31+ maxInterval = 5 * time .Second
32+ maxElapsedTime = elapsedMinutes * time .Minute
33+ )
34+
35+ exp := backoff .NewExponentialBackOff ()
36+ exp .InitialInterval = initialInterval
37+ exp .RandomizationFactor = randomizationFactor
38+ exp .Multiplier = multiplier
39+ exp .MaxInterval = maxInterval
40+ exp .MaxElapsedTime = maxElapsedTime
41+
42+ return exp
43+ }
44+
2445// downloadFile will download a url and store it in a temporary path.
2546// It writes to the destination file as it downloads it, without
2647// loading the entire file into memory.
@@ -38,20 +59,7 @@ func downloadFile(url string) (string, error) {
3859
3960 filepath := tempFile .Name ()
4061
41- var (
42- initialInterval = 500 * time .Millisecond
43- randomizationFactor = 0.5
44- multiplier = 2.0
45- maxInterval = 5 * time .Second
46- maxElapsedTime = 3 * time .Minute
47- )
48-
49- exp := backoff .NewExponentialBackOff ()
50- exp .InitialInterval = initialInterval
51- exp .RandomizationFactor = randomizationFactor
52- exp .Multiplier = multiplier
53- exp .MaxInterval = maxInterval
54- exp .MaxElapsedTime = maxElapsedTime
62+ exp := getExponentialBackOff (3 )
5563
5664 retryCount := 1
5765 var fileReader io.ReadCloser
0 commit comments