func()

in exponential/exponential.go [280:296]


func (b *Backoff) randomize(interval time.Duration) time.Duration {
	if b.policy.RandomizationFactor == 0 {
		return interval
	}

	// Calculate the random range.
	delta := b.policy.RandomizationFactor * float64(interval)
	min := interval - time.Duration(delta)
	max := interval + time.Duration(delta)

	if max-min <= 0 {
		return time.Duration(min)
	}
	// Get a random number in the range. So if RandomizationFactor is 0.5, and interval is 1s,
	// then we will get a random number between 0.5s and 1.5s.
	return time.Duration(rand.Int63n(int64(max-min))) + min // #nosec
}