https://github.com/vimeo/go-retry
A small package for doing comprehensive retries.
https://github.com/vimeo/go-retry
Last synced: 9 months ago
JSON representation
A small package for doing comprehensive retries.
- Host: GitHub
- URL: https://github.com/vimeo/go-retry
- Owner: vimeo
- License: apache-2.0
- Created: 2020-02-12T17:43:09.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2025-03-05T19:44:04.000Z (10 months ago)
- Last Synced: 2025-04-03T22:41:35.842Z (10 months ago)
- Language: Go
- Size: 36.1 KB
- Stars: 4
- Watchers: 17
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-retry

[](https://godoc.org/github.com/vimeo/go-retry)
`go-retry` is a package that helps facilitate retry logic with jittered
exponential backoff. It provides a convenient interface for configuring various
parameters. See below for more information.
## Example
```go
func makeNetworkCall(ctx context.Context) {
defaultBackoff := retry.DefaultBackoff()
// try at most 5 times
getErr := retry.Retry(ctx, defaultBackoff, 5, func(ctx context.Context) error {
response, err := http.Get("https://my.favorite.service")
if err != nil {
return err
}
// do something with response...
})
if getErr != nil {
// get failed, even after all the retries
}
}
```
Copyright Vimeo.