Skip to content

aniladanir/retry

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RETRY

Go Reference Go Report Card codecov

An implementation of capped exponential backoff algorithm with jitter.

Usage

// ...

// define condition
cond := func() bool {
    // try to establish connection to an external resource
    if err := TryConnect(); err != nil {
        return false
    }
    return true
}

// create a new retrier
retrier, err := retry.New(retry.DefaultConfiguration(), retry.DefaultRandomFunc)
if err != nil {
    panic(err)
}

// start retrying
notify := retrier.Retry(context.Background(), cond, true)

// wait for notification
<-notify

// ...

About

retry with exponential backoff

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages