Skip to content

Commit

Permalink
Merge pull request #118 from adjust/use-default-rand
Browse files Browse the repository at this point in the history
Use default rand in jitteredDuration
  • Loading branch information
psampaz authored Mar 23, 2022
2 parents 6edd67b + df60278 commit ee22f19
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ const (
purgeBatchSize = int64(100)
)

var randSrc = rand.New(rand.NewSource(time.Now().UnixNano()))

type Queue interface {
Publish(payload ...string) error
PublishBytes(payload ...[]byte) error
Expand Down Expand Up @@ -535,6 +533,6 @@ func (queue *redisQueue) ensureConsuming() error {

// jitteredDuration calculates and returns a value that is +/-10% the input duration
func jitteredDuration(duration time.Duration) time.Duration {
factor := 0.9 + randSrc.Float64()*0.2 // a jitter factor between 0.9 and 1.1 (+-10%)
factor := 0.9 + rand.Float64()*0.2 // a jitter factor between 0.9 and 1.1 (+-10%)
return time.Duration(float64(duration) * factor)
}

0 comments on commit ee22f19

Please sign in to comment.