A simple Go function for retrying functions on error, with exponential backoff
Go
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
LICENSE
README.md
attempt.go
retry.go
retry_test.go

README.md

Go retry

A simple Go function for retrying functions on error, with exponential backoff. Useful for calling external services which might occassionally fail.

Example

fn := func(attempt *Attempt) error {
    return functionWhichMightError()
}

err := Retry(fn, 5, time.Millisecond*500)

The code will run up to 5 times, until err == nil, with a delay between each run. The delay will increase exponentially. In this example, the delays will be 500ms, 1s, 2s, 4s.