From 7932967b33fbf6fb1818db5221fb7fd0264d43f6 Mon Sep 17 00:00:00 2001 From: Jan Seidl Date: Wed, 19 Oct 2022 22:20:48 +0200 Subject: [PATCH] version bump --- README.md | 22 ++++++++++++++++------ VERSION | 2 +- options.go | 17 ++++++++++------- 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index ccff937..bf2f648 100644 --- a/README.md +++ b/README.md @@ -228,6 +228,17 @@ func Attempts(attempts uint) Option Attempts set count of retry. Setting to 0 will retry until the retried function succeeds. default is 10 +#### func AttemptsForError + +```go +func AttemptsForError(attempts uint, err error) Option +``` +AttemptsForError sets count of retry in case execution results in given `err` +Retries for the given `err` are also counted against total retries. The retry +will stop if any of given retries is exhausted. + +added in 4.3.0 + #### func Context ```go @@ -344,13 +355,12 @@ wait for a set duration for retries. example of augmenting time.After with a print statement -type struct MyTimer {} func (t *MyTimer) After(d time.Duration) <- chan -time.Time { - - fmt.Print("Timer called!") - return time.After(d) +type struct MyTimer {} -} + func (t *MyTimer) After(d time.Duration) <- chan time.Time { + fmt.Print("Timer called!") + return time.After(d) + } retry.Do( diff --git a/VERSION b/VERSION index 6aba2b2..8089590 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.2.0 +4.3.0 diff --git a/options.go b/options.go index 630b631..ea9687f 100644 --- a/options.go +++ b/options.go @@ -62,6 +62,8 @@ func Attempts(attempts uint) Option { // AttemptsForError sets count of retry in case execution results in given `err` // Retries for the given `err` are also counted against total retries. // The retry will stop if any of given retries is exhausted. +// +// added in 4.3.0 func AttemptsForError(attempts uint, err error) Option { return func(c *Config) { c.attemptsForError[err] = attempts @@ -231,17 +233,18 @@ func Context(ctx context.Context) Option { // example of augmenting time.After with a print statement // // type struct MyTimer {} -// func (t *MyTimer) After(d time.Duration) <- chan time.Time { -// fmt.Print("Timer called!") -// return time.After(d) -// } // +// func (t *MyTimer) After(d time.Duration) <- chan time.Time { +// fmt.Print("Timer called!") +// return time.After(d) +// } // // retry.Do( -// func() error { ... }, -// retry.WithTimer(&MyTimer{}) -// ) // +// func() error { ... }, +// retry.WithTimer(&MyTimer{}) +// +// ) func WithTimer(t Timer) Option { return func(c *Config) { c.timer = t