Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrMaxRetries exceeded retry limit ErrMaxRetries = errors.New("exceeded retry limit") )
Functions ¶
func Do ¶
Do try to execute the interface, specify the number of attempts, and the execution interval
func DoFunc ¶
DoFunc try to execute a function, specify the number of attempts, and the execution interval
Example ¶
var ( count int value string ) err := DoFunc(3, func() error { if count > 1 { value = "foo" return nil } count++ return errors.New("not allowed") }, func(i int) time.Duration { return time.Millisecond * time.Duration(i) }) if err != nil { log.Fatalln(err.Error()) } fmt.Println(value)
Output: foo
Types ¶
Click to show internal directories.
Click to hide internal directories.