[ANN] backoff - Backoff iterator for Go 1.23+

50 views
Skip to first unread message

MZA

unread,
Dec 17, 2025, 12:32:16 PM (yesterday) Dec 17
to golang-nuts
Hi all,

I've released backoff, a small package for generating backoff durations in retry loops using Go 1.23+ iterators.

Basic usage:

```
for attempt := range backoff.Attempts(ctx, time.Second, 30*time.Second, backoff.Exponential(2), 5) {
    if err := doSomething(); err == nil {
        return nil
    }
}
return errors.New("max retries exceeded")
```

It supports linear, incremental and exponential step functions, as well as context cancelation, and jitter.

Feedback and contributions welcome!
Reply all
Reply to author
Forward
0 new messages