Skip to content

Commit

Permalink
fix: generate progression from IntervalSeconds & RetryLimit (#1813)
Browse files Browse the repository at this point in the history
  • Loading branch information
danvixent authored Oct 25, 2023
1 parent cafc57e commit 2302037
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions retrystrategies/retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,20 @@ type RetryStrategy interface {

func NewRetryStrategyFromMetadata(m datastore.Metadata) RetryStrategy {
if string(m.Strategy) == string(datastore.ExponentialStrategyProvider) {
// 10 seconds to 15 mins
return NewExponential([]uint{
10000, // 10 seconds
30000, // 30 seconds
60000, // 1 minute
180000, // 3 minutes
300000, // 5 minutes
600000, // 10 minutes
900000, // 15 minutes
})
return NewExponential(getProgression(uint(m.IntervalSeconds), uint(m.RetryLimit)))
}

return NewDefault(m.IntervalSeconds)
}

func getProgression(start, limit uint) []uint {
pgs := make([]uint, limit)

n := start
for i := range pgs {
pgs[i] = n
n *= 2
}

return pgs
}

0 comments on commit 2302037

Please sign in to comment.