Skip to content
This repository was archived by the owner on Oct 9, 2023. It is now read-only.

Commit b2383af

Browse files
Remove global lock in RateLimitStore
Signed-off-by: TungHoang <sontunghoang@gmail.com>
1 parent b35114b commit b2383af

File tree

1 file changed

+0
-4
lines changed

1 file changed

+0
-4
lines changed

plugins/rate_limit.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ type LimiterStore struct {
2929
accessPerUser *sync.Map
3030
requestPerSec int
3131
burstSize int
32-
mutex *sync.Mutex
3332
cleanupInterval time.Duration
3433
}
3534

@@ -55,8 +54,6 @@ func (l *LimiterStore) Allow(userID string) error {
5554

5655
// clean removes the access records for users who have not accessed the system for a while
5756
func (l *LimiterStore) clean() {
58-
l.mutex.Lock()
59-
defer l.mutex.Unlock()
6057
l.accessPerUser.Range(func(key, value interface{}) bool {
6158
value.(*accessRecords).mutex.Lock()
6259
defer value.(*accessRecords).mutex.Unlock()
@@ -70,7 +67,6 @@ func (l *LimiterStore) clean() {
7067
func newRateLimitStore(requestPerSec int, burstSize int, cleanupInterval time.Duration) *LimiterStore {
7168
l := &LimiterStore{
7269
accessPerUser: &sync.Map{},
73-
mutex: &sync.Mutex{},
7470
requestPerSec: requestPerSec,
7571
burstSize: burstSize,
7672
cleanupInterval: cleanupInterval,

0 commit comments

Comments
 (0)