Home

Awesome

retry-go

Small helper library to retry operations automatically on certain errors.

Usage

The retry package provides a Do() function which can be used to execute a provided function until it succeds.

op := func() error {
	// Do something that can fail and should be retried here
	return httpClient.CreateUserOnRemoteServer()
}
retry.Do(op, 
         retry.RetryChecker(IsNetOpErr),
         retry.Timeout(15 * time.Second))

Besides the op itself, you can provide a few options: