Improve polling producer error handling #47
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.
Closes #44, closes #35
This PR improves error handling for polling message production, by identifying the stage at which errors happen, then applying different logic depending on it.
Before
Before, any error occurring during message production (other than completion errors, recently worked on #45), would simply be caught, logged and polling would then proceed normally (with the typical delay between polling attempts).
Depending on the service usage patterns, this could have different, but in any case non-ideal results:
The first scenario is the most problematic, as it could contribute to further issues in the infrastructure, including making it harder to recover. Still, the second scenario is also not ideal, so it's relevant to take both into consideration.
With this PR
This PR addresses the aforementioned issues by better identifying the result of the production attempt, including the stage at which potential errors occur, then applying different logic depending on it:
* Note that the the interval increase is capped. With this PR the intervals are set at 1s, 5s, 30s, 1m and 5m, being this last one used until reset. This might change in the future, or even be made configurable, but for now, should be good enough.