Skip to content

Commit

Permalink
Merge pull request #6 from pamburus/feature/jitter
Browse files Browse the repository at this point in the history
fix: random source for jitter
  • Loading branch information
ssgreg authored Feb 13, 2020
2 parents 536dbd8 + f1f746a commit 803b320
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions backoff.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func FixedBackoff(delay time.Duration) *FixedBackoffBuilder {
// 7 random [0...30]
//
func FullJitterBackoffAlgorithm(baseDelay time.Duration, maxDelay time.Duration) func() time.Duration {
rnd := rand.New(rand.NewSource(int64(time.Now().Unix())))
rnd := rand.New(rand.NewSource(time.Now().UnixNano()))
delay := baseDelay

return func() time.Duration {
Expand Down Expand Up @@ -123,7 +123,7 @@ func FullJitterBackoff(baseDelay time.Duration) *FullJitterBackoffBuilder {
// 6 64 + random [-32...32] = 30
//
func ExponentialBackoffAlgorithm(initialDelay time.Duration, maxDelay time.Duration, multiplier float64, jitter float64) func() time.Duration {
rnd := rand.New(rand.NewSource(int64(time.Now().Unix())))
rnd := rand.New(rand.NewSource(time.Now().UnixNano()))
nextDelay := float64(initialDelay)
limit := float64(maxDelay)

Expand Down

0 comments on commit 803b320

Please sign in to comment.