Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,17 @@ func Retry(action Action, strategies ...strategy.Strategy) error {
// shouldAttempt evaluates the provided strategies with the given attempt to
// determine if the Retry loop should make another attempt.
func shouldAttempt(attempt uint, strategies ...strategy.Strategy) bool {
shouldAttempt := true

for i := 0; shouldAttempt && i < len(strategies); i++ {
shouldAttempt = shouldAttempt && strategies[i](attempt)
if len(strategies) > 0 {
// if strategy list isn't empty then processed them as usual
shouldAttempt := true

for i := 0; shouldAttempt && i < len(strategies); i++ {
shouldAttempt = shouldAttempt && strategies[i](attempt)
}

return shouldAttempt
} else {
// run action only one time
return attempt == 0
}

return shouldAttempt
}