feat: add missing htt StatusCode and make it settable#6051
feat: add missing htt StatusCode and make it settable#6051mhenselin wants to merge 5 commits intostackitcloud:mainfrom
Conversation
|
This PR was marked as stale after 7 days of inactivity and will be closed after another 7 days of further inactivity. If this PR should be kept open, just add a comment, remove the stale label or push new commits to it. |
|
This PR was closed automatically because it has been stalled for 7 days with no activity. Feel free to re-open it at any time. |
| ) | ||
|
|
||
| var RetryHttpErrorStatusCodes = []int{http.StatusBadGateway, http.StatusGatewayTimeout} | ||
| var RetryHttpErrorStatusCodes = []int{http.StatusBadGateway, http.StatusGatewayTimeout, http.StatusServiceUnavailable} |
There was a problem hiding this comment.
I've always assumed this is public to allow setting it. With this change I'd be in favour of deprecating this and making it private after the deprecation period.
There was a problem hiding this comment.
On the other hand this allows to express: "whatever the default is + sth. else" like:
myRetries := append(RetryHttpErrorStatusCodes, http.StatusRequestTimeout)
| } | ||
| // Some APIs may return temporary errors and the request should be retried | ||
| if !utils.Contains(RetryHttpErrorStatusCodes, oapiErr.StatusCode) { | ||
| if !utils.Contains(h.retryHttpErrorStatusCodes, oapiErr.StatusCode) { |
There was a problem hiding this comment.
| if !utils.Contains(h.retryHttpErrorStatusCodes, oapiErr.StatusCode) { | |
| if !slices.Contains(h.retryHttpErrorStatusCodes, oapiErr.StatusCode) { |
I'd prefer the builtin func instead of the utils one, if we are already touching this line
| got.SetTempErrRetryLimit(tt.tempErrRetryLimit) | ||
|
|
||
| diff := cmp.Diff(got, want, cmpOpts...) | ||
| diff := cmp.Diff(want, got, cmpOpts...) |
| } | ||
| // Some APIs may return temporary errors and the request should be retried | ||
| if !utils.Contains(RetryHttpErrorStatusCodes, oapiErr.StatusCode) { | ||
| if !utils.Contains(h.retryHttpErrorStatusCodes, oapiErr.StatusCode) { |
There was a problem hiding this comment.
We'd also need a fallback here when h.retryHttpErrrorStatusCodes == nil for people that did not use New but a AsyncActionHandler{} literal to create an instance.
Description
relates to #1234
Checklist
make fmtexamples/directory)make test(will be checked by CI)make lint(will be checked by CI)