Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // MemRatelimiterCacheExpiration MemRatelimiter key MemRatelimiterCacheExpiration = time.Minute * 60 // MemRatelimiterCacheCleanInterval MemRatelimiter MemRatelimiterCacheCleanInterval = time.Minute * 60 )
Functions ¶
func DefaultGinLimitKey ¶
DefaultGinLimitKey returns the default gin limit key
func DefaultGinLimitedHandler ¶
DefaultGinLimitedHandler 429
func GinMemRatelimiter ¶
func GinMemRatelimiter(conf GinRatelimiterConfig, logger *logger.Logger) gin.HandlerFunc
GinMemRatelimiter return the gin rate limiter handler func
Types ¶
type GinRatelimiterConfig ¶
type GinRatelimiterConfig struct { // LimitKey LimitKey func(*gin.Context) string // LimitedHandler LimitedHandler func(*gin.Context) // TokenBucketConfig TokenBucketConfig func(*gin.Context) (time.Duration, int) }
GinRatelimiterConfig Gin Ratelimiter
type MemRatelimiter ¶
type MemRatelimiter struct { *rate.Limiter *cache.Cache Expire time.Duration // contains filtered or unexported fields }
MemRatelimiter limiter
func NewMemRatelimiter ¶
func NewMemRatelimiter(logger *logger.Logger) *MemRatelimiter
NewMemRatelimiter mem limiter
Click to show internal directories.
Click to hide internal directories.