Skip to content

Commit 132a65c

Browse files
committed
Update options to define custom multiplier and randomization factor without backoff dependency
1 parent c5ed710 commit 132a65c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

options.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ package waitfor
22

33
import (
44
"time"
5-
6-
"github.com/cenkalti/backoff/v5"
75
)
86

97
type (
@@ -29,13 +27,15 @@ type (
2927
// - interval: 5 seconds
3028
// - maxInterval: 60 seconds
3129
// - attempts: 5.
30+
// - multiplier: 1.5
31+
// - randomizationFactor: 0.5
3232
func newOptions(setters []Option) *options {
3333
opts := &options{
3434
interval: time.Duration(5) * time.Second,
3535
maxInterval: time.Duration(60) * time.Second,
3636
attempts: 5,
37-
multiplier: backoff.DefaultMultiplier,
38-
randomizationFactor: backoff.DefaultRandomizationFactor,
37+
multiplier: 1.5,
38+
randomizationFactor: 0.5,
3939
}
4040

4141
for _, setter := range setters {
@@ -101,6 +101,10 @@ func WithMultiplier(multiplier float64) Option {
101101
// exponential backoff. This factor introduces jitter to the retry intervals,
102102
// helping to prevent thundering herd problems when multiple clients are retrying
103103
// simultaneously.
104+
//
105+
// Example:
106+
//
107+
// runner.Test(ctx, resources, waitfor.WithRandomizationFactor(0.5)) // 50% jitter
104108
func WithRandomizationFactor(factor float64) Option {
105109
return func(opts *options) {
106110
opts.randomizationFactor = factor

0 commit comments

Comments
 (0)