retry

package
v0.0.0-...-8964234 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 20, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Retry

func Retry(attempts int, sleep time.Duration, f func() error,
	logFunc func(error) string) error

func Run

func Run(r Next, f func() error, onError func(err error), onPanic func(x interface{})) bool

sync retry

func RunAsync

func RunAsync(r Next, f func() error, onError func(err error), onPanic func(x interface{})) chan bool

async retry

Types

type Counter

type Counter struct {
	Count int64    // retry times
	Wait  WaitFunc //mechanism
	// contains filtered or unexported fields
}

func (*Counter) Next

func (c *Counter) Next() bool

type Next

type Next interface {
	Next() bool
}

type WaitFunc

type WaitFunc func() time.Duration

back off mechanism 1.after fixed time 2.pow 10 millisecond

func NewBackOffWaitFunc

func NewBackOffWaitFunc() WaitFunc

0 10 100 1000 ...

func NewFixedWaitFunc

func NewFixedWaitFunc(d time.Duration) WaitFunc

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL