diff --git a/config/rateLimiter.go b/config/rateLimiter.go index 0ff606a..fc442ce 100644 --- a/config/rateLimiter.go +++ b/config/rateLimiter.go @@ -32,7 +32,7 @@ type RateLimiter struct { var rateLimiterInstance *RateLimiter var rateOnce sync.Once -func SetupRateLimiter(cfg *config.ServerConfig) { +func SetRateLimit(cfg *config.ServerConfig) { rateLimiter := NewRateLimiter( rate.Limit(cfg.RateLimit.WsLimit), cfg.RateLimit.WsBurst, diff --git a/config/setSizeLimit.go b/config/setSizeLimit.go index 651f302..cc1b0aa 100644 --- a/config/setSizeLimit.go +++ b/config/setSizeLimit.go @@ -12,13 +12,13 @@ type SizeLimiter struct { mu sync.RWMutex } -func SetupSizeLimiter(cfg *config.ServerConfig) { +func SetSizeLimit(cfg *config.ServerConfig) { sizeLimiter := NewSizeLimiter(cfg.RateLimit.MaxEventSize) for _, kindSizeLimit := range cfg.RateLimit.KindSizeLimits { sizeLimiter.AddKindSizeLimit(kindSizeLimit.Kind, kindSizeLimit.MaxSize) } - SetSizeLimit(sizeLimiter) + SizeLimit(sizeLimiter) } func NewSizeLimiter(globalMaxSize int) *SizeLimiter { @@ -35,7 +35,7 @@ func GetSizeLimiter() *SizeLimiter { return sizeLimiterInstance } -func SetSizeLimit(sl *SizeLimiter) { +func SizeLimit(sl *SizeLimiter) { sizeOnce.Do(func() { sizeLimiterInstance = sl }) diff --git a/main.go b/main.go index 2db3fd6..43b476e 100644 --- a/main.go +++ b/main.go @@ -46,8 +46,8 @@ func main() { log.Fatal("Error initializing database: ", err) } - config.SetupRateLimiter(cfg) - config.SetupSizeLimiter(cfg) + config.SetRateLimit(cfg) + config.SetSizeLimit(cfg) config.ClearTemporaryBans()