Skip to content

TonyPath/retrier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Retrier

codecov Go Report Card go.mod Go version GoDoc

Simple retrier in Go

Examples

maxAttempts := 5
backoffInMillis := 1000
retrier, _ := NewPeriodicRetrier(maxAttempts, backoffInMillis)

res, err := retrier.Retry(
	func() (any, error) {
            res, err := http.Get(...)
            return res, err
	}, 
	func(err error) bool {
            var errDNS *net.DNSError
            if errors.As(err, &errDNS) && errDNS.IsTemporary {
                return true
            }
            return false
        }
)

About

A Golang package that provides a simple retry mechanism

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages