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

mark CheckError as experimental feature and add typical mistakes #163

Open
1 task
kamilsk opened this issue Jan 18, 2021 · 1 comment
Open
1 task

mark CheckError as experimental feature and add typical mistakes #163

kamilsk opened this issue Jan 18, 2021 · 1 comment

Comments

@kamilsk
Copy link
Owner

kamilsk commented Jan 18, 2021

retry/strategy/strategy.go

Lines 102 to 144 in 19175c7

// ErrorHandler defines a function that CheckError can use
// to determine whether it should make the next attempt or not.
// Returning true allows for the next attempt to be made.
// Returning false halts the retrying process and returns the last error
// returned by the called Action.
type ErrorHandler func(error) bool
// CheckError creates a Strategy that checks an error and returns
// if an error is retriable or not. Otherwise, it returns the defaults.
func CheckError(handlers ...func(error) bool) Strategy {
// equal to go.octolab.org/errors.Retriable
type retriable interface {
error
Retriable() bool // Is the error retriable?
}
return func(_ Breaker, _ uint, err error) bool {
if err == nil {
return true
}
if err, is := err.(retriable); is {
return err.Retriable()
}
for _, handle := range handlers {
if !handle(err) {
return false
}
}
return true
}
}
// NetworkError creates an error Handler that checks an error and returns true
// if an error is the temporary network error.
// The Handler returns the defaults if an error is not a network error.
func NetworkError(defaults bool) func(error) bool {
return func(err error) bool {
if err, is := err.(net.Error); is {
return err.Temporary() || err.Timeout()
}
return defaults
}
}

TODO:

  • find bad case usage from goreleaser
@kamilsk kamilsk self-assigned this Jan 18, 2021
@kamilsk kamilsk added this to Backlog in Performance improvements via automation Jan 18, 2021
@kamilsk kamilsk removed this from Backlog in Performance improvements Jan 18, 2021
@kamilsk kamilsk added this to the retry 5.0 milestone Jan 18, 2021
@kamilsk
Copy link
Owner Author

kamilsk commented Sep 24, 2023

goreleaser

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant