Skip to content

yumimobi/retrying

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

retrying

Retrying is a golang binding of python retrying library https://github.com/rholder/retrying

Build Status Go Report Card codecov

Installation

$ go get github.com/yumimobi/retrying

Usage

package main

import (
	"fmt"
	"math/rand"
	"time"

	"github.com/yumimobi/retrying"
)

func init() {
	rand.Seed(time.Now().UnixNano())
}

func main() {
	err := retrying.New().
		Stack(2048, true).
		MaxAttemptTimes(5).
		Function(func() error {
			if rand.Int63n(100) > 80 {
				return nil
			}
			return fmt.Errorf("dllm")
		}).
		WaitFixed(time.Second).
		WaitRandom(time.Second, time.Second*3).
		MaxDelay(time.Minute).
		Try()

	fmt.Println(err == nil)
}

About

Retrying is a golang binding of python retrying library https://github.com/rholder/retrying

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages