Skip to content

rossy0213/retry

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Retry codecov

Retry with context or not.

Default using exponential backoff.

Example

func DoSomething() error {
	err := retry.Do( // use DoWithContext() if you need context
		doSomeThing(),
		retry.CheckRetryable(checkRetryable),
		retry.MaxRetryTimes(uint(5)),
		retry.Interval(100.0*time.Millisecond),
		retry.MaxInterval(5000.0*time.Millisecond),
		retry.MaxJitterInterval(10.0*time.Millisecond),
		retry.MaxElapsedTime(10*time.Minute),
		retry.Multiplier(1.5),
	)
	return err
}

func doSomething() error {
    return retryableErr
}

func checkRetryable(err error) bool {
    if err == retryableErr {
        return true
    }
    return false
}

Default parameters

DefaultMaxRetryTimes  = 10
DefaultInterval       = 100.0 * time.Millisecond
DefaultMaxInterval    = 1000.0 * time.Millisecond
DefaultJitterInterval = 30.0 * time.Millisecond
DefaultMultiplier     = 2.0
DefaultMaxElapsedTime = 5 * time.Minute

Reference

backoff

retry-go

retry

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages