Install:
go get github.com/singlestore-labs/wait
Wait provides one function: For
.
err := wait.For(func() (bool, error) {
err := trySomething()
if err != nil {
if isFatal(err) {
return false, err
}
return false, nil
}
return true, nil
})
It calls its function argument over and over until:
- a timeout occurs (failure)
- the bool becomes true (success or failure depending on error)
- if ExitOnError(true) and the error becomes non nil (failure)