Skip to content

Commit

Permalink
Added retry on the rest of Get calls
Browse files Browse the repository at this point in the history
  • Loading branch information
michalfranc-form3 committed Oct 2, 2019
1 parent 0475962 commit 04504b2
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions auth0/auth0_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,11 @@ func (authClient *AuthClient) DeleteUserById(id string) error {
// Client
func (authClient *AuthClient) GetClientById(id string) (*Client, error) {

resp, body, errs := gorequest.New().Get(authClient.config.apiUri+"clients/"+id).Set("Authorization", authClient.config.getAuthenticationHeader()).End()
resp, body, errs := gorequest.New().
Get(authClient.config.apiUri+"clients/"+id).
Set("Authorization", authClient.config.getAuthenticationHeader()).
Retry(authClient.config.maxRetryCount, authClient.config.timeBetweenRetries, http.StatusTooManyRequests).
End()

if resp.StatusCode >= 400 && resp.StatusCode != 404 {
return nil, fmt.Errorf("bad status code (%d): %s", resp.StatusCode, body)
Expand Down Expand Up @@ -327,7 +331,11 @@ func (authClient *AuthClient) DeleteClientById(id string) error {
// Api
func (authClient *AuthClient) GetApiById(id string) (*Api, error) {

resp, body, errs := gorequest.New().Get(authClient.config.apiUri+"resource-servers/"+id).Set("Authorization", authClient.config.getAuthenticationHeader()).End()
resp, body, errs := gorequest.New().
Get(authClient.config.apiUri+"resource-servers/"+id).
Set("Authorization", authClient.config.getAuthenticationHeader()).
Retry(authClient.config.maxRetryCount, authClient.config.timeBetweenRetries, http.StatusTooManyRequests).
End()

if resp.StatusCode >= 400 && resp.StatusCode != 404 {
return nil, fmt.Errorf("bad status code (%d): %s", resp.StatusCode, body)
Expand Down Expand Up @@ -419,6 +427,7 @@ func (authClient *AuthClient) GetClientGrantById(id string) (*ClientGrant, error
_, body, errs := gorequest.New().
Get(authClient.config.apiUri+"client-grants").
Set("Authorization", authClient.config.getAuthenticationHeader()).
Retry(authClient.config.maxRetryCount, authClient.config.timeBetweenRetries, http.StatusTooManyRequests).
End()

if errs != nil {
Expand Down Expand Up @@ -451,6 +460,7 @@ func (authClient *AuthClient) GetClientGrantByClientIdAndAudience(clientId strin
resp, body, errs := gorequest.New().
Get(authClient.config.apiUri+"client-grants").
Query(queryParams).Set("Authorization", authClient.config.getAuthenticationHeader()).
Retry(authClient.config.maxRetryCount, authClient.config.timeBetweenRetries, http.StatusTooManyRequests).
End()

if resp.StatusCode >= 400 && resp.StatusCode != 404 {
Expand Down

0 comments on commit 04504b2

Please sign in to comment.