Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RateLimiter ¶
type RateLimiter struct {
// contains filtered or unexported fields
}
RateLimiter implements a token bucket rate limiter
func (*RateLimiter) Allow ¶
func (rl *RateLimiter) Allow() bool
type UserRateLimiter ¶
type UserRateLimiter struct {
// contains filtered or unexported fields
}
UserRateLimiter manages rate limiting for multiple users
func New ¶
func New(rate float64, capacity float64, expirationTime time.Duration) *UserRateLimiter
NewUserRateLimiter creates a new UserRateLimiter instance
func OncePerMinute ¶
func OncePerMinute() *UserRateLimiter
func OncePerSecond ¶
func OncePerSecond() *UserRateLimiter
func Rps10 ¶
func Rps10() *UserRateLimiter
func Rps100 ¶
func Rps100() *UserRateLimiter
func Rps1000 ¶
func Rps1000() *UserRateLimiter
func (*UserRateLimiter) Allow ¶
func (url *UserRateLimiter) Allow(userID string) bool
Allow checks if a request should be allowed for a given user
Click to show internal directories.
Click to hide internal directories.