4 ms·
Not only that, but now that Go has iterators if you need this in several locations the logic of the original can easily be encapsulated in an iterator with a fe
by masklinn 1y ago
Not only that, but now that Go has iterators if you need this in several locations the logic of the original can easily be encapsulated in an iterator with a few relevant tunable knobs, and then you just write something like:
for range ExponentialBackoff(ctx) {
err := request(ctx)
if err == nil {
return nil
}
}
and if one of the callsites needs to configure the backoff then you've got something like:
for range ExponentialBackoff(ctx, MaxAttempts(20), BaseDelay(5)) {
err := request(ctx)
if err == nil {
return nil
}
}