From 2f8d0cc3d9a354899309c7f258028d5661910f16 Mon Sep 17 00:00:00 2001 From: Matt Reiferson Date: Sun, 12 Sep 2021 15:39:57 -0700 Subject: [PATCH] config: use explicit int64 for random durations --- config.go | 2 +- config_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config.go b/config.go index d799c5ff..644aaac8 100644 --- a/config.go +++ b/config.go @@ -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) { diff --git a/config_test.go b/config_test.go index 060b0739..791c2c23 100644 --- a/config_test.go +++ b/config_test.go @@ -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, }