Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use default rand in jitteredDuration #118

Merged
merged 1 commit into from
Mar 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
use default rand
  • Loading branch information
psampaz committed Mar 23, 2022
commit df60278bb0565d2ab6e647ac9f51945ee9942e4a
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)
}