func newTokenBucket(capacity int64, tokenInterval time.Duration) *tokenBucket {
	tb := tokenBucket{
		capacity:       capacity,
		tokenInterval:  tokenInterval,
		refillDuration: tokenInterval * time.Duration(capacity)}

	tb.earliestUnspentToken = tb.capacityToken()

	return &tb
}
func newTokenBucket(capacity int64, tokenInterval time.Duration) *tokenBucket {
	tb := tokenBucket{
		capacity:       capacity,
		tokenInterval:  tokenInterval,
		refillDuration: tokenInterval * time.Duration(capacity)}

	tb.earliestUnspentToken = tb.capacityToken()

	return &tb
}
func newTokenBucket ( capacity int64 , tokenInterval time . Duration ) * tokenBucket { tb := tokenBucket { capacity : capacity , tokenInterval : tokenInterval , refillDuration : tokenInterval * time . Duration ( capacity ) } tb . earliestUnspentToken = tb . capacityToken ( ) return & tb }
// newTokenBucket returns a bucket containing capacity tokens, refilled at a
// rate of one token per tokenInterval.
newTokenBucket returns a bucket containing capacity tokens refilled at a rate of one token per tokenInterval .