fixes from bucky's review

This commit is contained in:
Anton Kaliaev
2018-03-11 13:20:51 +04:00
parent f85c8896d9
commit 0f41570c80
2 changed files with 15 additions and 12 deletions

View File

@ -254,10 +254,8 @@ func (c *WSClient) reconnect() error {
c.mtx.Unlock()
}()
// 1s == (1e9 ns) == (1 Billion ns)
billionNs := float64(time.Second.Nanoseconds())
for {
jitterSeconds := time.Duration(rand.Float64() * billionNs)
jitterSeconds := time.Duration(rand.Float64() * float64(time.Second)) // 1s == (1e9 ns)
backoffDuration := jitterSeconds + ((1 << uint(attempt)) * time.Second)
c.Logger.Info("reconnecting", "attempt", attempt+1, "backoff_duration", backoffDuration)