Skip to content

Commit

Permalink
Update cluster_client.go
Browse files Browse the repository at this point in the history
adding 401 status code retry
  • Loading branch information
vfolgosa authored Aug 3, 2022
1 parent 92bb5e1 commit a42f99e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ccloud/cluster/cluster_client.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cluster

import (
"context"
"encoding/json"
"fmt"
"net/http"
Expand Down Expand Up @@ -41,6 +42,14 @@ func (c *ConfluentClusterClient) doRequest(base string, urlPath, method string,
client := retryablehttp.NewClient()
client.RetryMax = 10

client.CheckRetry = func(ctx context.Context, resp *http.Response, err error) (bool, error) {
ok, e := retryablehttp.DefaultRetryPolicy(ctx, resp, err)
if !ok && (resp.StatusCode == http.StatusUnauthorized || resp.StatusCode >= 500 && resp.StatusCode != 501) {
return true, e
}
return ok, nil
}

if base == "" {
base = c.BaseUrl
}
Expand Down

0 comments on commit a42f99e

Please sign in to comment.