-
Notifications
You must be signed in to change notification settings - Fork 172
Open
Description
It seems that when using attempts=0, any value that's passed to attemptsForError is ignored in function
DoWithData
If this is the intended design, shouldn't they be mutual exclusive? Warning? Panic? I suppose error is out of the question due to the api...
IMO it makes more sense to apply the logic of attemptsForError also when attempts=0, but whatever decided please document it.
thanks.
Here's a link to playground that
https://go.dev/play/p/N4DaCm_UWcA
package main
import (
"context"
"fmt"
"testing"
"time"
"github.com/avast/retry-go/v4"
)
func TestRetry(t *testing.T) {
someFunc := func() error {
fmt.Print("attempt\n")
return context.Canceled
}
retry.Do(someFunc, retry.Delay(20*time.Millisecond), retry.AttemptsForError(1, context.Canceled))
fmt.Print("work without infinite loop\n")
retry.Do(someFunc, retry.Attempts(0), retry.Delay(20*time.Millisecond), retry.AttemptsForError(1, context.Canceled))
}
Metadata
Metadata
Assignees
Labels
No labels