Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaime Martinez <jmartinez@gitlab.com>2021-09-15 05:24:13 +0300
committerJaime Martinez <jmartinez@gitlab.com>2021-09-15 05:24:13 +0300
commita954b0d0832b3abff37e26380f2aaac8b1f65fb7 (patch)
tree358411b435bc43f01b8e3e5c37d35d8a0c6e285d
parent9d8e2ec112f0d2b33705511bb9aed5d33ab1938e (diff)
chore: cleanup unused fields490-poc-rate-limiting
-rw-r--r--internal/ratelimiter/ratelimit.go21
1 files changed, 0 insertions, 21 deletions
diff --git a/internal/ratelimiter/ratelimit.go b/internal/ratelimiter/ratelimit.go
index 63342cea..70a30294 100644
--- a/internal/ratelimiter/ratelimit.go
+++ b/internal/ratelimiter/ratelimit.go
@@ -8,11 +8,6 @@ import (
)
const (
- // DefaultCleanupInterval is the time at which cleanup will run
- DefaultCleanupInterval = 30 * time.Second
- // DefaultMaxTimePerDomain is the maximum time to keep a domain in the rate limiter map
- DefaultMaxTimePerDomain = 30 * time.Second
-
// DefaultPerDomainFrequency the maximum number of requests per second to be allowed per domain.
// The default value of 25ms equals 1 request every 25ms -> 40 rps
DefaultPerDomainFrequency = 25 * time.Millisecond
@@ -27,11 +22,6 @@ const (
defaultDomainsExpirationInterval = time.Hour
)
-type counter struct {
- limiter *rate.Limiter
- lastSeen time.Time
-}
-
// Option function to configure a RateLimiter
type Option func(*RateLimiter)
@@ -42,8 +32,6 @@ type Option func(*RateLimiter)
// the time since counter.lastSeen is greater than the domainMaxTTL.
type RateLimiter struct {
now func() time.Time
- cleanupTimer *time.Ticker
- domainMaxTTL time.Duration
perDomainFrequency time.Duration
perDomainBurstSize int
//domainMux *sync.RWMutex
@@ -55,8 +43,6 @@ type RateLimiter struct {
func New(opts ...Option) *RateLimiter {
rl := &RateLimiter{
now: time.Now,
- cleanupTimer: time.NewTicker(DefaultCleanupInterval),
- domainMaxTTL: DefaultMaxTimePerDomain,
perDomainFrequency: DefaultPerDomainFrequency,
perDomainBurstSize: DefaultPerDomainBurstSize,
//domainMux: &sync.RWMutex{},
@@ -77,13 +63,6 @@ func WithNow(now func() time.Time) Option {
}
}
-// WithCleanupInterval replaces the RateLimiter cleanup interval
-func WithCleanupInterval(d time.Duration) Option {
- return func(rl *RateLimiter) {
- rl.cleanupTimer.Reset(d)
- }
-}
-
// WithPerDomainFrequency allows configuring perDomain frequency for the RateLimiter
func WithPerDomainFrequency(d time.Duration) Option {
return func(rl *RateLimiter) {