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

Commit 2195181

Browse files
Add configs for rate limit
1 parent 45b9c46 commit 2195181

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

pkg/config/config.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,10 @@ type SslOptions struct {
9191

9292
// declare RateLimitConfig
9393
type RateLimitOptions struct {
94-
RequestsPerSecond int
95-
BurstSize int
96-
CleanupInterval config.Duration
94+
Enabled bool `json:"enabled"`
95+
RequestsPerSecond int `json:"requestsPerSecond"`
96+
BurstSize int `json:"burstSize"`
97+
CleanupInterval config.Duration `json:"cleanupInterval"`
9798
}
9899

99100
var defaultServerConfig = &ServerConfig{

plugins/rate_limit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type Limiter struct {
2727
// define a function named Allow that takes userID and returns RateLimitError
2828
// the function check if the user is in the map, if not, create a new accessRecords for the user
2929
// then it check if the user can access the resource, if not, return RateLimitError
30-
func (l *Limiter) Allow(userID string) RateLimitError {
30+
func (l *Limiter) Allow(userID string) error {
3131
l.mutex.Lock()
3232
defer l.mutex.Unlock()
3333
if _, ok := l.accessPerUser[userID]; !ok {

0 commit comments

Comments
 (0)