logging failed attempt in a logger #622
Replies: 2 comments
-
Just saw that I can do that inside of r.AddRetryCondition(
func(r *resty.Response, err error) bool {
if r.StatusCode() > 299 || r.StatusCode() == 0 {
log.L.Warn( // zerolog
err, "main", "httpclient",
fmt.Sprintf("%s %s - %s", r.Request.Method, r.Request.URL, r.Status()),
)
}
return r.Header().Get("Should-Retry") == "true" ||
(r.StatusCode() == http.StatusTooManyRequests ||
r.StatusCode() == http.StatusServiceUnavailable ||
r.StatusCode() == http.StatusGatewayTimeout)
},
) I noticed that func (r *Response) StatusCode() int {
if r.RawResponse == nil {
return 0
}
return r.RawResponse.StatusCode
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
Details about 503 - https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/503 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I'm searching a way to log the failed attempt when
Resty
tries to reach a service that is not available.I've found
OnError
but it's triggered once all attempts have been reached.Thx
Beta Was this translation helpful? Give feedback.
All reactions