https://github.com/rafaeljesus/retry-go
Retrying made simple and easy for golang :repeat:
https://github.com/rafaeljesus/retry-go
distributed-systems go resiliency
Last synced: 7 months ago
JSON representation
Retrying made simple and easy for golang :repeat:
- Host: GitHub
- URL: https://github.com/rafaeljesus/retry-go
- Owner: rafaeljesus
- License: mit
- Created: 2017-06-09T16:07:37.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-10-25T12:14:03.000Z (about 7 years ago)
- Last Synced: 2025-04-05T03:12:42.660Z (8 months ago)
- Topics: distributed-systems, go, resiliency
- Language: Go
- Homepage:
- Size: 7.81 KB
- Stars: 50
- Watchers: 1
- Forks: 6
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go - retry-go - Retrying made simple and easy for golang - ★ 24 (Utilities)
- awesome-go - retry-go - Retrying made simple and easy for golang. (Utilities / Advanced Console UIs)
- awesome-go-extra - retry-go - 06-09T16:07:37Z|2018-10-25T12:14:03Z| (Utilities / Fail injection)
- awesome-go-cn - retry-go
- awesome-go-cn - retry-go - go) [![godoc][D]](https://godoc.org/github.com/rafaeljesus/retry-go) (公用事业公司 / 实用程序/Miscellaneous)
- awesome-go-plus - retry-go - Retrying made simple and easy for golang.  (Utilities / Utility/Miscellaneous)
- awesome-go - retry-go - Retrying made simple and easy for golang. (Utilities / Utility/Miscellaneous)
- awesome-go - retry-go - | - | - | (Utilities / HTTP Clients)
- awesome-go - retry-go - Retrying made simple and easy for golang. (Utilities / Utility/Miscellaneous)
- awesome-go-with-stars - retry-go - Retrying made simple and easy for golang. (Utilities / Utility/Miscellaneous)
- awesome-go - retry-go - Retrying made simple and easy for golang. (Utilities / Utility/Miscellaneous)
- awesome-go - retry-go - Retrying made simple and easy for golang. (Utilities / Utility/Miscellaneous)
- awesome-Char - retry-go - Retrying made simple and easy for golang. (Utilities / HTTP Clients)
- awesome-go - retry-go - Retrying made simple and easy for golang. - :arrow_down:4 - :star:21 (Utilities / HTTP Clients)
- awesome-go-cn - retry-go - go) [![godoc][D]](https://godoc.org/github.com/rafaeljesus/retry-go) (公用事业公司 / 实用程序/Miscellaneous)
- awesome-go - retry-go - Retrying made simple and easy for golang. (Utilities / HTTP Clients)
README
# retry-go
* Retrying made simple and easy for golang.
## Installation
```bash
go get -u github.com/rafaeljesus/retry-go
```
## Usage
### Do
```go
package main
import (
"time"
"github.com/rafaeljesus/retry-go"
)
func main() {
attempts := 3
sleepTime := time.Second*2
if err := retry.Do(func() error {
return work()
}, attempts, sleepTime); err != nil {
// Retry failed
}
}
```
### DoHTTP
```go
package main
import (
"time"
"github.com/rafaeljesus/retry-go"
)
func main() {
attempts := 3
sleepTime := time.Second*2
if err := retry.DoHTTP(func() (*http.Response, error) {
return makeRequest()
}, attempts, sleepTime); err != nil {
// Retry failed
}
}
```
## Contributing
- Fork it
- Create your feature branch (`git checkout -b my-new-feature`)
- Commit your changes (`git commit -am 'Add some feature'`)
- Push to the branch (`git push origin my-new-feature`)
- Create new Pull Request
## Badges
[](https://circleci.com/gh/rafaeljesus/retry-go)
[](https://goreportcard.com/report/github.com/rafaeljesus/retry-go)
[](https://godoc.org/github.com/rafaeljesus/retry-go)
---
> GitHub [@rafaeljesus](https://github.com/rafaeljesus) ·
> Medium [@_jesus_rafael](https://medium.com/@_jesus_rafael) ·
> Twitter [@_jesus_rafael](https://twitter.com/_jesus_rafael)