Skip to content

Commit

Permalink
version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Seidl committed Oct 19, 2022
1 parent 169733a commit 7932967
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 14 deletions.
22 changes: 16 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.2.0
4.3.0
17 changes: 10 additions & 7 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7932967

Please sign in to comment.