3 ms·
Similar to your suggestion, I implemented a wrapper around retries in Go before and despite liking the lookup table version quite a lot, I think it's more impor
by mariusor 1y ago
Similar to your suggestion, I implemented a wrapper around retries in Go before and despite liking the lookup table version quite a lot, I think it's more important to be able to parametrize the initial duration of the back-off and also the rate at which it grows, so that's what I focused on.
I'm not sure how my example fares against on a simplicity scale, but it feels a little more readable to me:
Retry(5, BackOff(time.Second, Linear(1.4), func(_ context.Context) { // do stuff } )
Example cribbed from the documentation: https://pkg.go.dev/git.sr.ht/~mariusor/ssm#StrategyFn https://pkg.go.dev/git.sr.ht/~mariusor/ssm#StrategyFn