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

internal/backoff: add a helper to run a function with backoff #6661

Merged
merged 3 commits into from
Sep 26, 2023

Conversation

easwars
Copy link
Contributor

@easwars easwars commented Sep 25, 2023

Fixes #5813

RELEASE NOTES: none

@easwars easwars requested a review from dfawley September 25, 2023 17:01
@easwars easwars added the Type: Internal Cleanup Refactors, etc label Sep 25, 2023
@easwars easwars added this to the 1.59 Release milestone Sep 25, 2023
Copy link
Member

@dfawley dfawley left a comment

Choose a reason for hiding this comment

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

LGTM in concept. Some suggestions for the API itself. I especially find it odd that the error is not returned by RunF, but that isn't necessarily a problem, as you can set things in the f closure you pass.

internal/backoff/backoff.go Outdated Show resolved Hide resolved
internal/backoff/backoff.go Outdated Show resolved Hide resolved
@dfawley dfawley assigned easwars and unassigned dfawley Sep 25, 2023
@easwars easwars assigned dfawley and unassigned easwars Sep 25, 2023
orca/producer.go Outdated
if resetBackoff {
retErr = backoff.ErrResetBackoff
}
if code := status.Code(err); code == codes.Unavailable || code == codes.Canceled {
Copy link
Member

Choose a reason for hiding this comment

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

Reworking the ordering here should simplify a little:

if code := status.Code(err); code != Unavailable && code != Canceled {
	logger.Error()
}
if resetBackoff {
	return backoff.ErrResetBackoff
}
return nil

internal/backoff/backoff.go Outdated Show resolved Hide resolved
@dfawley dfawley assigned easwars and unassigned dfawley Sep 25, 2023
@easwars easwars merged commit 57cb4d8 into grpc:master Sep 26, 2023
10 checks passed
@easwars easwars deleted the backoff_func branch September 26, 2023 18:10
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a helper to run an arbitrary function with backoff
2 participants