Skip to content

Commit b5c967a

Browse files
committed
address comments
1 parent 2eecede commit b5c967a

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

utils/types.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,20 +133,18 @@ func (kc *KongClientConfig) ForWorkspace(name string) KongClientConfig {
133133
// (HTTP Code 429) is found in the resp parameter. Hence it will return the number of
134134
// seconds the server states it may be ready to process more requests from this client.
135135
//
136-
// This is the same as DefaultBackoff (https://github.com/hashicorp/go-retryablehttp/blob/master/client.go#L510)
136+
// This is the same as DefaultBackoff (https://github.com/hashicorp/go-retryablehttp/blob/v0.7.1/client.go#L503)
137137
// except that here we are only retrying on 429s.
138138
func backoffStrategy(min, max time.Duration, attemptNum int, resp *http.Response) time.Duration {
139139
const (
140140
base = 10
141141
bitSize = 64
142142
baseExponential = 2
143143
)
144-
if resp != nil {
145-
if resp.StatusCode == http.StatusTooManyRequests {
146-
if s, ok := resp.Header["Retry-After"]; ok {
147-
if sleep, err := strconv.ParseInt(s[0], base, bitSize); err == nil {
148-
return time.Second * time.Duration(sleep)
149-
}
144+
if resp != nil && resp.StatusCode == http.StatusTooManyRequests {
145+
if s, ok := resp.Header["Retry-After"]; ok {
146+
if sleep, err := strconv.ParseInt(s[0], base, bitSize); err == nil {
147+
return time.Second * time.Duration(sleep)
150148
}
151149
}
152150
}

0 commit comments

Comments
 (0)