Skip to content

Commit c4b9021

Browse files
committed
Testing
1 parent 4a897c5 commit c4b9021

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

internal/api/client.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ func (c *Client) ExecuteWithRetry(
8585
}
8686

8787
var fn = func() (response *Response, backoff time.Duration, err error) {
88+
fmt.Println("Executing request to endpoint:", endpointCfg.Method, endpointCfg.Url)
8889
req, err := http.NewRequest(endpointCfg.Method, endpointCfg.Url, bytes.NewReader(requestBody))
8990
if err != nil {
9091
return nil, dur, fmt.Errorf("%s: %w", errors.ErrConstructingRequest, err)
@@ -110,6 +111,7 @@ func (c *Client) ExecuteWithRetry(
110111
case endpointCfg.SuccessStatus:
111112
// success case
112113
case http.StatusTooManyRequests:
114+
fmt.Println("TOO MANY REQs:", endpointCfg.Method, endpointCfg.Url)
113115
header := apiRes.Header.Get("Retry-After")
114116
retryAfter, err := strconv.Atoi(header)
115117
if err != nil {
@@ -123,6 +125,7 @@ func (c *Client) ExecuteWithRetry(
123125
})
124126
return nil, dur, errors.ErrRatelimit
125127
case http.StatusGatewayTimeout:
128+
fmt.Println("TIMEOUT:", endpointCfg.Method, endpointCfg.Url)
126129
var apiError Error
127130
if err := json.Unmarshal(responseBody, &apiError); err != nil {
128131
return nil, dur, fmt.Errorf(
@@ -136,6 +139,7 @@ func (c *Client) ExecuteWithRetry(
136139

137140
return nil, dur, errors.ErrGatewayTimeout
138141
default:
142+
fmt.Println("UNEXPECTED CODE:", endpointCfg.Method, endpointCfg.Url, apiRes.StatusCode, string(responseBody))
139143
var apiError Error
140144
if err := json.Unmarshal(responseBody, &apiError); err != nil {
141145
return nil, dur, fmt.Errorf(
@@ -195,6 +199,7 @@ func exec(
195199
if backOff > 0 {
196200
timer.Reset(backOff)
197201
} else {
202+
fmt.Println("Retrying request")
198203
timer.Reset(waitOnReattempt)
199204
}
200205
}

0 commit comments

Comments
 (0)