func (this *BaseRateLimiter) GenerateCacheKeys(request *pb.RateLimitRequest,
	limits []*config.RateLimit, hitsAddend uint32) []CacheKey {
	assert.Assert(len(request.Descriptors) == len(limits))
	cacheKeys := make([]CacheKey, len(request.Descriptors))
	now := this.timeSource.UnixNow()
	for i := 0; i < len(request.Descriptors); i++ {
		cacheKeys[i] = this.cacheKeyGenerator.GenerateCacheKey(request.Domain, request.Descriptors[i], limits[i], now)
		if limits[i] != nil {
			limits[i].Stats.TotalHits.Add(uint64(hitsAddend))
		}
	}
	return cacheKeys
}
Generates cache keys for given rate limit request. Each cache key is represented by a concatenation of
domain, descriptor and current timestamp.
package limiter
import (
	"math"
	"math/rand"
	"github.com/coocood/freecache"
	pb "github.com/envoyproxy/go-control-plane/envoy/service/ratelimit/v3"
	logger "github.com/sirupsen/logrus"
	"github.com/envoyproxy/ratelimit/src/assert"
	"github.com/envoyproxy/ratelimit/src/config"
	"github.com/envoyproxy/ratelimit/src/stats"
	"github.com/envoyproxy/ratelimit/src/utils"
)
type BaseRateLimiter struct {
	timeSource                 utils.TimeSource
	JitterRand                 *rand.Rand
	ExpirationJitterMaxSeconds int64
	cacheKeyGenerator          CacheKeyGenerator
	localCache                 *freecache.Cache
	nearLimitRatio             float32
	StatsManager               stats.Manager
}
type LimitInfo struct {
	limit               *config.RateLimit
	limitBeforeIncrease uint32
	limitAfterIncrease  uint32
	nearLimitThreshold  uint32
	overLimitThreshold  uint32
}
func NewRateLimitInfo(limit *config.RateLimit, limitBeforeIncrease uint32, limitAfterIncrease uint32,
	nearLimitThreshold uint32, overLimitThreshold uint32) *LimitInfo {
	return &LimitInfo{
		limit: limit, limitBeforeIncrease: limitBeforeIncrease, limitAfterIncrease: limitAfterIncrease,
		nearLimitThreshold: nearLimitThreshold, overLimitThreshold: overLimitThreshold,
	}
}