mirror of
https://github.com/0ceanSlim/grain.git
synced 2024-11-25 01:43:23 +00:00
rearranged some limiter structs
This commit is contained in:
parent
aa62bcf3da
commit
8956eeea63
@ -19,10 +19,10 @@ type CategoryLimiter struct {
|
||||
}
|
||||
|
||||
type RateLimiter struct {
|
||||
eventLimiter *rate.Limiter
|
||||
wsLimiter *rate.Limiter
|
||||
kindLimiters map[int]*KindLimiter
|
||||
eventLimiter *rate.Limiter
|
||||
categoryLimiters map[string]*CategoryLimiter
|
||||
kindLimiters map[int]*KindLimiter
|
||||
mu sync.RWMutex
|
||||
}
|
||||
|
||||
@ -39,12 +39,12 @@ func GetRateLimiter() *RateLimiter {
|
||||
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{
|
||||
eventLimiter: rate.NewLimiter(eventLimit, eventBurst),
|
||||
wsLimiter: rate.NewLimiter(wsLimit, wsBurst),
|
||||
kindLimiters: make(map[int]*KindLimiter),
|
||||
eventLimiter: rate.NewLimiter(eventLimit, eventBurst),
|
||||
categoryLimiters: make(map[string]*CategoryLimiter),
|
||||
kindLimiters: make(map[int]*KindLimiter),
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user