Retry
Retry a function execution with specific intervals with panic recovery
Make sure to read the docs to understand how this package works and what do expected from it.
Installation
go get -u github.com/txgruppi/retry-go
Example
package main
import (
"log"
"time"
"github.com/txgruppi/retry-go"
)
func main() {
toTry := func(attempt, limit int) error {
// Do you stuff and return an error if there is any
return nil
}
err := retry.WithFixedInterval(1 * time.Second, 5, toTry)
if err != nil {
log.Fatal(err) // It should log the errors if there were any
}
}
Tests
go get -u -t github.com/txgruppi/retry-go
cd $GOPATH/src/github.com/txgruppi/retry-go
go test ./...
License
MIT