Skip to content

Commit

Permalink
Merge 669c09b into 272ad12
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilsk committed Jul 18, 2016
2 parents 272ad12 + 669c09b commit b5b0a35
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions retry.go
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
}

0 comments on commit b5b0a35

Please sign in to comment.