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

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.

GitHub

View Github