mirror of
https://github.com/bwmarrin/discordgo.git
synced 2025-12-23 23:17:45 -05:00
feat(restapi): retry on 500s, 503s, 504s as well as 502s (#1586)
This commit is contained in:
@@ -267,6 +267,12 @@ func (s *Session) RequestWithLockedBucket(method, urlStr, contentType string, b
|
||||
case http.StatusOK:
|
||||
case http.StatusCreated:
|
||||
case http.StatusNoContent:
|
||||
case http.StatusInternalServerError:
|
||||
fallthrough
|
||||
case http.StatusServiceUnavailable:
|
||||
fallthrough
|
||||
case http.StatusGatewayTimeout:
|
||||
fallthrough
|
||||
case http.StatusBadGateway:
|
||||
// Retry sending request if possible
|
||||
if sequence < cfg.MaxRestRetries {
|
||||
@@ -276,7 +282,7 @@ func (s *Session) RequestWithLockedBucket(method, urlStr, contentType string, b
|
||||
} else {
|
||||
err = fmt.Errorf("Exceeded Max retries HTTP %s, %s", resp.Status, response)
|
||||
}
|
||||
case 429: // TOO MANY REQUESTS - Rate limiting
|
||||
case http.StatusTooManyRequests:
|
||||
rl := TooManyRequests{}
|
||||
err = Unmarshal(response, &rl)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user