Skip to content

Commit

Permalink
Improvements to example in README
Browse files Browse the repository at this point in the history
  • Loading branch information
csueiras authored Feb 26, 2021
1 parent ce11b3c commit cee11ee
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ r := runner.NewFactory(
3. Optionally create your predicate for errors that shouldn't be retried

```
errPredicate := func(method string, err error) bool {
// shouldRetryErrPredicate is a predicate that ignores the "NotFound" errors emited by the DoOperation in Client. All other errors
// are eligible for the middlewares.
shouldRetryErrPredicate := func(method string, err error) bool {
if method == reinforced.ClientMethods.DoOperation && errors.Is(client.NotFound, err) {
return false
}
Expand All @@ -126,7 +128,7 @@ c := client.NewClient(...)
// reinforcedClient implements the target interface so it can now be used in lieau of any place where the unreliable
// client was used
reinforcedClient := reinforced.NewClient(c, r, reinforced.WithRetryableErrorPredicate(errPredicate))
reinforcedClient := reinforced.NewClient(c, r, reinforced.WithRetryableErrorPredicate(shouldRetryErrPredicate))
```

A complete example is [here](./example/main.go)

0 comments on commit cee11ee

Please sign in to comment.