starpit commented on a change in pull request #46: Add retry support to every
request
URL:
https://github.com/apache/incubator-openwhisk-client-go/pull/46#discussion_r154114259
##########
File path: whisk/client.go
##########
@@ -316,98 +319,118 @@ func BodyTruncator(body io.ReadCloser) (string,
io.ReadCloser, error) {
return string(data), reload, nil
}
+func retry(attempts int, sleep time.Duration, callback func() (*http.Response,
error)) (*http.Response, error) {
+ var err error
+ var resp *http.Response
+ for i := 0; ; i++ {
+ resp, err = callback()
Review comment:
the logic is actually a bit subtle. i have this in a branch of the openwhisk
npm -- where i've needed to use retries for a while, now.
the following status codes should never be retried:
```
statusCode === 400 || statusCode === 401 || statusCode === 404 || statusCode
=== 409 || statusCode === 410 || statusCode === 500
```
if the statusCode is 502... then we probably also shouldn't retry.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services