Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 3 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 7 years ago)
- Default Branch: master
- Last Pushed: 2018-10-25T12:14:03.000Z (about 6 years ago)
- Last Synced: 2024-06-18T16:57:29.361Z (5 months ago)
- Topics: distributed-systems, go, resiliency
- Language: Go
- Homepage:
- Size: 7.81 KB
- Stars: 48
- Watchers: 2
- Forks: 5
- 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-extra - retry-go - 06-09T16:07:37Z|2018-10-25T12:14:03Z| (Utilities / Fail injection)
README
# retry-go
* Retrying made simple and easy for golang.
## Installation
```bash
go get -u github.com/rafaeljesus/retry-go
```## Usage
### Do
```go
package mainimport (
"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 mainimport (
"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
[![Build Status](https://circleci.com/gh/rafaeljesus/retry-go.svg?style=svg)](https://circleci.com/gh/rafaeljesus/retry-go)
[![Go Report Card](https://goreportcard.com/badge/github.com/rafaeljesus/retry-go)](https://goreportcard.com/report/github.com/rafaeljesus/retry-go)
[![Go Doc](https://godoc.org/github.com/rafaeljesus/retry-go?status.svg)](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)