File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -111,7 +111,9 @@ r := runner.NewFactory(
111
111
3 . Optionally create your predicate for errors that shouldn't be retried
112
112
113
113
```
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 {
115
117
if method == reinforced.ClientMethods.DoOperation && errors.Is(client.NotFound, err) {
116
118
return false
117
119
}
@@ -126,7 +128,7 @@ c := client.NewClient(...)
126
128
127
129
// reinforcedClient implements the target interface so it can now be used in lieau of any place where the unreliable
128
130
// client was used
129
- reinforcedClient := reinforced.NewClient(c, r, reinforced.WithRetryableErrorPredicate(errPredicate ))
131
+ reinforcedClient := reinforced.NewClient(c, r, reinforced.WithRetryableErrorPredicate(shouldRetryErrPredicate ))
130
132
```
131
133
132
134
A complete example is [ here] ( ./example/main.go )
You can’t perform that action at this time.
0 commit comments