|
|
@@ -1,7 +1,6 @@
|
|
1
|
1
|
package relay
|
|
2
|
2
|
|
|
3
|
3
|
import (
|
|
4
|
|
- "math"
|
|
5
|
4
|
"math/rand"
|
|
6
|
5
|
"time"
|
|
7
|
6
|
)
|
|
|
@@ -15,12 +14,9 @@ func getTimeout() time.Duration {
|
|
15
|
14
|
}
|
|
16
|
15
|
|
|
17
|
16
|
func getTime(minDuration, maxDuration time.Duration) time.Duration {
|
|
18
|
|
- minDurationInSeconds := minDuration.Seconds()
|
|
19
|
|
- maxDurationInSeconds := maxDuration.Seconds()
|
|
20
|
|
- middle := minDurationInSeconds + (maxDurationInSeconds-minDurationInSeconds)/2 // nolint: gomnd
|
|
21
|
|
-
|
|
22
|
|
- number := minDurationInSeconds + rand.ExpFloat64()*middle
|
|
23
|
|
- number = math.Round(math.Min(maxDurationInSeconds, number))
|
|
|
17
|
+ minDurationInSeconds := int(minDuration.Seconds())
|
|
|
18
|
+ maxDurationInSeconds := int(maxDuration.Seconds())
|
|
|
19
|
+ number := minDurationInSeconds + rand.Intn(maxDurationInSeconds-minDurationInSeconds)
|
|
24
|
20
|
|
|
25
|
21
|
return time.Duration(number) * time.Second
|
|
26
|
22
|
}
|