Documentation
¶
Index ¶
Constants ¶
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type RateLimiter ¶
type RateLimiter struct {
// contains filtered or unexported fields
}
RateLimiter manages rate limiters with expiration
func NewRateLimiter ¶
func NewRateLimiter(cfg *Config) (*RateLimiter, error)
NewRateLimiter creates a rate limiter with TTL and cleanup
func (*RateLimiter) Allow ¶
func (r *RateLimiter) Allow(key string) bool
Allow checks if the key can perform an action now
func (*RateLimiter) GetLimiter ¶
func (r *RateLimiter) GetLimiter(key string) *rate.Limiter
GetLimiter returns or creates a rate limiter for a key
func (*RateLimiter) Shutdown ¶
func (r *RateLimiter) Shutdown()
Shutdown stops the background cleanup goroutine (safe to call multiple times)
func (*RateLimiter) ShutdownWithContext ¶
func (r *RateLimiter) ShutdownWithContext(ctx context.Context) error
ShutdownWithContext stops cleanup goroutine with timeout
func (*RateLimiter) Start ¶
func (r *RateLimiter) Start()
Start begins the cleanup goroutine (safe to call multiple times)
Click to show internal directories.
Click to hide internal directories.