|
|
@ -5,6 +5,12 @@ import (
|
|
|
|
"time"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
|
|
|
// minRate is the minimum rate at which we allow an action to be performed
|
|
|
|
|
|
|
|
// acorss the whole cluster. The value is once a day: 1 / (1 * time.Day)
|
|
|
|
|
|
|
|
minRate = 1.0 / 86400
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// DurationMinusBuffer returns a duration, minus a buffer and jitter
|
|
|
|
// DurationMinusBuffer returns a duration, minus a buffer and jitter
|
|
|
|
// subtracted from the duration. This function is used primarily for
|
|
|
|
// subtracted from the duration. This function is used primarily for
|
|
|
|
// servicing Consul TTL Checks in advance of the TTL.
|
|
|
|
// servicing Consul TTL Checks in advance of the TTL.
|
|
|
@ -43,7 +49,6 @@ func RandomStagger(intv time.Duration) time.Duration {
|
|
|
|
// order to target an aggregate number of actions per second across the whole
|
|
|
|
// order to target an aggregate number of actions per second across the whole
|
|
|
|
// cluster.
|
|
|
|
// cluster.
|
|
|
|
func RateScaledInterval(rate float64, min time.Duration, n int) time.Duration {
|
|
|
|
func RateScaledInterval(rate float64, min time.Duration, n int) time.Duration {
|
|
|
|
const minRate = 1 / 86400 // 1/(1 * time.Day)
|
|
|
|
|
|
|
|
if rate <= minRate {
|
|
|
|
if rate <= minRate {
|
|
|
|
return min
|
|
|
|
return min
|
|
|
|
}
|
|
|
|
}
|
|
|
|