package try
import "github.com/matryer/try"
Package try provides retry functionality.
var value string err := try.Do(func(attempt int) (bool, error) { var err error value, err = SomeFunction() return attempt < 5, err // try 5 times }) if err != nil { log.Fatalln("error:", err) }
Index ¶
Variables ¶
var MaxRetries = 10
MaxRetries is the maximum number of retries before bailing.
Functions ¶
func Do ¶
Do keeps trying the function until the second argument returns false, or no error is returned.
func IsMaxRetries ¶
IsMaxRetries checks whether the error is due to hitting the maximum number of retries or not.
Types ¶
type Func ¶
Func represents functions that can be retried.
Source Files ¶
- Version
- v0.0.0-20161228173917-9ac251b645a2 (latest)
- Published
- Dec 28, 2016
- Platform
- linux/amd64
- Imports
- 1 packages
- Last checked
- 2 hours ago –
Tools for package owners.