Skip to content

Commit

Permalink
config: use explicit int64 for random durations
Browse files Browse the repository at this point in the history
  • Loading branch information
mreiferson committed Sep 12, 2021
1 parent 37690ba commit 2f8d0cc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (s *FullJitterStrategy) Calculate(attempt int) time.Duration {

backoffDuration := s.cfg.BackoffMultiplier *
time.Duration(math.Pow(2, float64(attempt)))
return time.Duration(s.rng.Intn(int(backoffDuration)))
return time.Duration(s.rng.Int63n(int64(backoffDuration)))
}

func (s *FullJitterStrategy) setConfig(cfg *Config) {
Expand Down
4 changes: 2 additions & 2 deletions config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ func TestExponentialBackoff(t *testing.T) {

func TestFullJitterBackoff(t *testing.T) {
expected := []time.Duration{
566028617 * time.Nanosecond,
1365407263 * time.Nanosecond,
724039541 * time.Nanosecond,
1603903257 * time.Nanosecond,
5232470547 * time.Nanosecond,
21467499218 * time.Nanosecond,
}
Expand Down

0 comments on commit 2f8d0cc

Please sign in to comment.