Skip to content

Commit 2302037

Browse files
authoredOct 25, 2023
fix: generate progression from IntervalSeconds & RetryLimit (frain-dev#1813)
1 parent cafc57e commit 2302037

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed
 

‎retrystrategies/retry.go

+13-10
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,20 @@ type RetryStrategy interface {
1313

1414
func NewRetryStrategyFromMetadata(m datastore.Metadata) RetryStrategy {
1515
if string(m.Strategy) == string(datastore.ExponentialStrategyProvider) {
16-
// 10 seconds to 15 mins
17-
return NewExponential([]uint{
18-
10000, // 10 seconds
19-
30000, // 30 seconds
20-
60000, // 1 minute
21-
180000, // 3 minutes
22-
300000, // 5 minutes
23-
600000, // 10 minutes
24-
900000, // 15 minutes
25-
})
16+
return NewExponential(getProgression(uint(m.IntervalSeconds), uint(m.RetryLimit)))
2617
}
2718

2819
return NewDefault(m.IntervalSeconds)
2920
}
21+
22+
func getProgression(start, limit uint) []uint {
23+
pgs := make([]uint, limit)
24+
25+
n := start
26+
for i := range pgs {
27+
pgs[i] = n
28+
n *= 2
29+
}
30+
31+
return pgs
32+
}

0 commit comments

Comments
 (0)