Make the retry middleware more flexible #582
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation / Background
This PR addresses the issue #571. The idea here is to allow clients to specify exactly which errors are retryable or not.
Retryable errors are typically caused by transient failures such as timeouts or connection issues.
However, there may be cases where certain errors are known to be non-retryable, for example, malformed input messages.
This change adds a ShouldRetry parameter to the retry middleware configuration, allowing clients to explicitly define which errors should be retried and which should not.
Detail
At the company I work for, we use a custom error package that allows us to have a fine control of which errors are retryable or not.
So, it would be great if the Retry middleware could be customized to ignore those errors we already know
that are not retryable.
Alternative approaches considered (if applicable)
Not considered!
Checklist