func newRatioController(tm timetools.TimeProvider, rampUp time.Duration) *ratioController { return &ratioController{ duration: rampUp, tm: tm, start: tm.UtcNow(), } }
// newTokenBucket crates a `tokenBucket` instance for the specified `Rate`. func newTokenBucket(rate *rate, clock timetools.TimeProvider) *tokenBucket { return &tokenBucket{ period: rate.period, timePerToken: time.Duration(int64(rate.period) / rate.average), burst: rate.burst, clock: clock, lastRefresh: clock.UtcNow(), availableTokens: rate.burst, } }