rearranged some limiter structs

This commit is contained in:
Chris kerr 2024-07-25 21:33:42 -04:00
parent aa62bcf3da
commit 8956eeea63

View File

@ -19,10 +19,10 @@ type CategoryLimiter struct {
} }
type RateLimiter struct { type RateLimiter struct {
eventLimiter *rate.Limiter
wsLimiter *rate.Limiter wsLimiter *rate.Limiter
kindLimiters map[int]*KindLimiter eventLimiter *rate.Limiter
categoryLimiters map[string]*CategoryLimiter categoryLimiters map[string]*CategoryLimiter
kindLimiters map[int]*KindLimiter
mu sync.RWMutex mu sync.RWMutex
} }
@ -39,12 +39,12 @@ func GetRateLimiter() *RateLimiter {
return rateLimiterInstance return rateLimiterInstance
} }
func NewRateLimiter(eventLimit rate.Limit, eventBurst int, wsLimit rate.Limit, wsBurst int) *RateLimiter { func NewRateLimiter(wsLimit rate.Limit, wsBurst int, eventLimit rate.Limit, eventBurst int) *RateLimiter {
return &RateLimiter{ return &RateLimiter{
eventLimiter: rate.NewLimiter(eventLimit, eventBurst),
wsLimiter: rate.NewLimiter(wsLimit, wsBurst), wsLimiter: rate.NewLimiter(wsLimit, wsBurst),
kindLimiters: make(map[int]*KindLimiter), eventLimiter: rate.NewLimiter(eventLimit, eventBurst),
categoryLimiters: make(map[string]*CategoryLimiter), categoryLimiters: make(map[string]*CategoryLimiter),
kindLimiters: make(map[int]*KindLimiter),
} }
} }