Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve validation.LimitError usages #6954

Merged
merged 2 commits into from
Dec 20, 2023
Merged

Improve validation.LimitError usages #6954

merged 2 commits into from
Dec 20, 2023

Conversation

duricanikolic
Copy link
Contributor

@duricanikolic duricanikolic commented Dec 18, 2023

What this PR does

This PR improves usages of validation.LimitError errors. It addresses the following problems found in the code:

  • In case of an unexpected behaviour, functions limiter.AddSeries(), limiter.AddChunkBytes(), limiter.AddChunks() and limiter.AddEstimatedChunks() return an error of type validate.LimitError. In some cases, the caller of those functions used to wrap the returned error into validation.LimitError, although it was not necessary. In order to prevent this, the signature of the above mentioned methods has been changed from func AddXyz(...) error to func AddXyz(...) validation.LimitError. This way we enforced that the only allowed errors returned by these functions are of type validation.LimitError.
  • Type validation.LimitError is now an interface, instead of a struct as it used to be.

Checklist

  • Tests updated.
  • [na] Documentation added.
  • [na] CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX].
  • about-versioning.md updated with experimental features.

@duricanikolic duricanikolic self-assigned this Dec 18, 2023
@duricanikolic duricanikolic force-pushed the yuri/limit-errors branch 2 times, most recently from 6fca7b2 to b85e37c Compare December 18, 2023 17:56
Signed-off-by: Yuri Nikolic <durica.nikolic@grafana.com>
@duricanikolic duricanikolic marked this pull request as ready for review December 18, 2023 18:07
@duricanikolic duricanikolic requested a review from a team as a code owner December 18, 2023 18:07
Copy link
Contributor

@dimitarvdimitrov dimitarvdimitrov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks

Comment on lines 337 to 339
quorumConfig.IsTerminalError = func(err error) bool {
_, isLimitError := err.(validation.LimitError)
return isLimitError
return validation.IsLimitError(err)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we do this?

quorumConfig.IsTerminalError = validaiton.IsLimitError

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, will replace it. Thank you

Signed-off-by: Yuri Nikolic <durica.nikolic@grafana.com>
@duricanikolic duricanikolic merged commit bcbf687 into main Dec 20, 2023
28 checks passed
@duricanikolic duricanikolic deleted the yuri/limit-errors branch December 20, 2023 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants