Skip to content

Commit

Permalink
issue1808: cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
DariaFedorova committed Nov 10, 2024
1 parent 6a55de0 commit 4993792
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions query_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,33 +169,35 @@ func (q *queryExecutor) do(ctx context.Context, qry ExecutableQuery, hostIter Ne
if iter.err == nil || rt == nil {
return iter
}
// Exit if error is ignored or retry attempts were reached

retryType := rt.GetRetryType(iter.err)
if retryType == Ignore {
iter.err = nil
return iter
}
if !rt.Attempt(qry) {
return iter
}
attemptsReached := !rt.Attempt(qry)

lastErr = iter.err
var stopRetries bool

// If query is unsuccessful, check the error with RetryPolicy to retry
switch rt.GetRetryType(iter.err) {
switch retryType {
case Retry:
// retry on the same host
continue
case Rethrow:
return iter
case RetryNextHost:
// retry on the next host
selectedHost = hostIter()
continue
case Ignore:
iter.err = nil
stopRetries = true
case Rethrow:
stopRetries = true
default:
// Undefined? Return nil and error, this will panic in the requester
return &Iter{err: ErrUnknownRetryType}
}

if stopRetries || attemptsReached {
return iter
}

lastErr = iter.err
continue
}

if lastErr != nil {
Expand Down

0 comments on commit 4993792

Please sign in to comment.