-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
faucet: rate limit initial implementation #2603
Conversation
cmd/faucet/faucet.go
Outdated
limiter := f.limiter.GetLimiter(ip) | ||
if !limiter.Allow() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as you are not using limiter
maybe better approach will be to implement f.limiter.Allow(ip)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks much better 👍
cmd/faucet/rate_limiter.go
Outdated
return i, nil | ||
} | ||
|
||
func (i *IPRateLimiter) AddIP(ip string) *rate.Limiter { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if AddIP
is only for internal usage, we can name it: addIP
cmd/faucet/rate_limiter.go
Outdated
type IPRateLimiter struct { | ||
ips *lru.Cache | ||
r rate.Limit | ||
b int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better to add some comments for b
, it is the burst value within 5min?
Description
This PR introduces some rate limiting for faucet.
Also couple of concurrencies being introduced so that the main loop doesn't potentially get stuck in one single request.
Addressing issue: #2606
Rationale
tell us why we need these changes...
Example
add an example CLI or API response...
Changes
Notable changes: