Skip to content

Commit cee11ee

Browse files
authored
Improvements to example in README
1 parent ce11b3c commit cee11ee

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ r := runner.NewFactory(
111111
3. Optionally create your predicate for errors that shouldn't be retried
112112

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

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

0 commit comments

Comments
 (0)