File tree Expand file tree Collapse file tree 3 files changed +27
-14
lines changed Expand file tree Collapse file tree 3 files changed +27
-14
lines changed Original file line number Diff line number Diff line change @@ -228,6 +228,17 @@ func Attempts(attempts uint) Option
228228Attempts set count of retry. Setting to 0 will retry until the retried function
229229succeeds. default is 10
230230
231+ #### func AttemptsForError
232+
233+ ` ` ` go
234+ func AttemptsForError(attempts uint, err error) Option
235+ ` ` `
236+ AttemptsForError sets count of retry in case execution results in given ` err`
237+ Retries for the given ` err` are also counted against total retries. The retry
238+ will stop if any of given retries is exhausted.
239+
240+ added in 4.3.0
241+
231242#### func Context
232243
233244` ` ` go
@@ -344,13 +355,12 @@ wait for a set duration for retries.
344355
345356example of augmenting time.After with a print statement
346357
347- type struct MyTimer {} func (t *MyTimer) After(d time.Duration) <- chan
348- time.Time {
349-
350- fmt.Print("Timer called!")
351- return time.After(d)
358+ type struct MyTimer {}
352359
353- }
360+ func (t *MyTimer) After(d time.Duration) <- chan time.Time {
361+ fmt.Print("Timer called!")
362+ return time.After(d)
363+ }
354364
355365retry.Do(
356366
Original file line number Diff line number Diff line change 1- 4.2 .0
1+ 4.3 .0
Original file line number Diff line number Diff line change @@ -62,6 +62,8 @@ func Attempts(attempts uint) Option {
6262// AttemptsForError sets count of retry in case execution results in given `err`
6363// Retries for the given `err` are also counted against total retries.
6464// The retry will stop if any of given retries is exhausted.
65+ //
66+ // added in 4.3.0
6567func AttemptsForError (attempts uint , err error ) Option {
6668 return func (c * Config ) {
6769 c .attemptsForError [err ] = attempts
@@ -231,17 +233,18 @@ func Context(ctx context.Context) Option {
231233// example of augmenting time.After with a print statement
232234//
233235// type struct MyTimer {}
234- // func (t *MyTimer) After(d time.Duration) <- chan time.Time {
235- // fmt.Print("Timer called!")
236- // return time.After(d)
237- // }
238236//
237+ // func (t *MyTimer) After(d time.Duration) <- chan time.Time {
238+ // fmt.Print("Timer called!")
239+ // return time.After(d)
240+ // }
239241//
240242// retry.Do(
241- // func() error { ... },
242- // retry.WithTimer(&MyTimer{})
243- // )
244243//
244+ // func() error { ... },
245+ // retry.WithTimer(&MyTimer{})
246+ //
247+ // )
245248func WithTimer (t Timer ) Option {
246249 return func (c * Config ) {
247250 c .timer = t
You can’t perform that action at this time.
0 commit comments