Skip to content

Commit

Permalink
fixup! fix: increase code coverage
Browse files Browse the repository at this point in the history
Signed-off-by: Yoan Blanc <yblanc@edgelab.ch>
  • Loading branch information
greut committed Sep 16, 2020
1 parent 9f2d72d commit 3efdc7f
Showing 1 changed file with 18 additions and 38 deletions.
56 changes: 18 additions & 38 deletions httpclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,52 +157,32 @@ outter:
if err != nil {
multiErr.Push(err.Error())
c.reportError(request, err)

backoffTime := c.retrier.NextInterval(i)
ctx, cancel := context.WithTimeout(context.Background(), backoffTime)

select {
case <-ctx.Done():
cancel()

continue

case <-request.Context().Done():
cancel()

multiErr.Push(request.Context().Err().Error())
c.reportError(request, request.Context().Err())

// If the request context has already been cancelled, don't retry
break outter
}
} else {
c.reportRequestEnd(request, response)
}

c.reportRequestEnd(request, response)

if response.StatusCode >= http.StatusInternalServerError {
backoffTime := c.retrier.NextInterval(i)
ctx, cancel := context.WithTimeout(context.Background(), backoffTime)
if err == nil && response.StatusCode < http.StatusInternalServerError {
// Clear errors if any iteration succeeds
multiErr = &valkyrie.MultiError{}
break
}

select {
case <-ctx.Done():
cancel()
backoffTime := c.retrier.NextInterval(i)
ctx, cancel := context.WithTimeout(context.Background(), backoffTime)

continue
select {
case <-ctx.Done():
cancel()

case <-request.Context().Done():
cancel()
case <-request.Context().Done():
cancel()

multiErr.Push(request.Context().Err().Error())
c.reportError(request, request.Context().Err())
multiErr.Push(request.Context().Err().Error())
c.reportError(request, request.Context().Err())

// If the request context has already been cancelled, don't retry
break outter
}
// If the request context has already been cancelled, don't retry
break outter
}

multiErr = &valkyrie.MultiError{} // Clear errors if any iteration succeeds
break
}

return response, multiErr.HasError()
Expand Down

0 comments on commit 3efdc7f

Please sign in to comment.