Skip to content

Simple tool to repeat (or retry) some actions after some time for GoLang

License

Notifications You must be signed in to change notification settings

makssof/retrool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Retrool

Simple tool to repeat (or retry) some actions after some time for GoLang.

The tool determines whether an action should be retried by the action's return value

GoDoc Release License

Content

Installation

To install the package just run:

go get -u github.com/makssof/retrool

Usage

import "github.com/makssof/retrool"

func main() {
    rand.Seed(time.Now().UnixNano())

    // tryOptions := retrool.DefaultTryOptions
    tryOptions := &retrool.TryOptions{
        StartInterval:        1,
        Addition:             1,
        AdditionCoefficient:  0.5,
        MaxTries:             10, 
        FailureDecisionMaker: retrool.DefaultDecisionMaker,
    }

    var n int

    retrool.Try(tryOptions, func (i int) bool {
        n = rand.Intn(101)

        return n < 10
    })
}

Contribution

The tool is open-sourced under the MIT license.

If you will find some error, want to add something or ask a question - feel free to create an issue and/or make a pull request.

Any contribution is welcome.

About

Simple tool to repeat (or retry) some actions after some time for GoLang

Topics

Resources

License

Stars

Watchers

Forks

Languages