Skip to content

Commit 2d07a0c

Browse files
committed
NotNil -> notNil
1 parent 922f426 commit 2d07a0c

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

retry.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ func Timeout(timeout, delay time.Duration, f func() error) error {
3535

3636
var errCeilLessThanFloor = errors.New("ceiling cannot be less than the floor")
3737

38-
// NotNil is a condition function that if passed to a Backoff,
38+
// notNil is a condition function that if passed to a Backoff,
3939
// will continue retrying until the error is nil.
40-
func NotNil(err error) bool { return err != nil }
40+
func notNil(err error) bool { return err != nil }
4141

4242
// Backoff implements an exponential backoff algorithm.
4343
// It calls f before timeout is exceeded using ceil as a maximum sleep
@@ -46,7 +46,7 @@ func NotNil(err error) bool { return err != nil }
4646
// it will return by timeout.
4747
// If timeout is 0, it will run until the function returns a nil error.
4848
func Backoff(timeout, ceil, floor time.Duration, f func() error) error {
49-
return BackoffWhile(timeout, ceil, floor, f, NotNil)
49+
return BackoffWhile(timeout, ceil, floor, f, notNil)
5050
}
5151

5252
// BackoffWhile implements an exponential backoff algorithm.
@@ -95,7 +95,7 @@ func BackoffWhile(timeout, ceil, floor time.Duration, f func() error, cond func(
9595
// It calls f before the context is cancelled using ceil as a maximum sleep
9696
// interval and floor as the start interval.
9797
func BackoffContext(ctx context.Context, ceil, floor time.Duration, f func() error) error {
98-
return BackoffContextWhile(ctx, ceil, floor, f, NotNil)
98+
return BackoffContextWhile(ctx, ceil, floor, f, notNil)
9999
}
100100

101101
func BackoffContextWhile(ctx context.Context, ceil, floor time.Duration, f func() error, cond func(error) bool) error {

retry_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ func TestBackoffWhile(t *testing.T) {
133133
BackoffWhile(time.Second, time.Millisecond*5, time.Millisecond, func() error {
134134
time.Sleep(time.Millisecond * 5)
135135
return io.EOF
136-
}, NotNil,
136+
}, notNil,
137137
)
138138

139139
assert.WithinDuration(t, start.Add(time.Second), time.Now(), time.Millisecond*10)
@@ -146,7 +146,7 @@ func TestBackoffWhile(t *testing.T) {
146146
return nil
147147
}
148148
return io.EOF
149-
}, NotNil,
149+
}, notNil,
150150
)
151151

152152
require.NoError(t, err)
@@ -156,7 +156,7 @@ func TestBackoffWhile(t *testing.T) {
156156
err := BackoffWhile(0, 0, 5, func() error {
157157
t.Fatal("should not be called?")
158158
return nil
159-
}, NotNil,
159+
}, notNil,
160160
)
161161

162162
require.Equal(t, errCeilLessThanFloor, err)
@@ -200,7 +200,7 @@ func TestBackoffContextWhile(t *testing.T) {
200200
return nil
201201
}
202202
return io.EOF
203-
}, NotNil,
203+
}, notNil,
204204
)
205205

206206
assert.Equal(t, 10, count)
@@ -213,7 +213,7 @@ func TestBackoffContextWhile(t *testing.T) {
213213
start := time.Now()
214214
BackoffContextWhile(ctx, time.Millisecond*5, time.Millisecond, func() error {
215215
return io.EOF
216-
}, NotNil,
216+
}, notNil,
217217
)
218218

219219
assert.WithinDuration(t, start.Add(time.Millisecond*100), time.Now(), time.Millisecond*10)

0 commit comments

Comments
 (0)