Use http constants and use switch instead of if

This commit is contained in:
Robert Neumayer 2021-02-10 16:46:00 +01:00
parent bcd60c3895
commit 50a6732859
1 changed files with 3 additions and 1 deletions

View File

@ -6,6 +6,7 @@ import (
"fmt"
"math"
"math/rand"
"net/http"
"regexp"
"sync/atomic"
"time"
@ -28,7 +29,8 @@ var retryPolicy = &common.RetryPolicy{
ShouldRetryOperation: func(res common.OCIOperationResponse) bool {
var e common.ServiceError
if errors.As(res.Error, &e) {
if e.GetHTTPStatusCode() == 429 || e.GetHTTPStatusCode() == 500 || e.GetHTTPStatusCode() == 503 {
switch e.GetHTTPStatusCode() {
case http.StatusTooManyRequests, http.StatusInternalServerError, http.StatusServiceUnavailable:
return true
}
}