Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Limiter ¶
type Limiter struct {
// contains filtered or unexported fields
}
Limiter 用于存储令牌桶与键值对名称的映射关系
type LimiterBucketRule ¶
type LimiterBucketRule struct { Key string // 自定义键值对名称 FillInterval time.Duration // 间隔多久时间放 N 个令牌 Capacity int64 // 令牌桶的容量 Quantum int64 // 每次到达间隔时间后所放的具体令牌数量 }
LimiterBucketRule 用于存储令牌桶的一些相应规则属性
type LimiterIface ¶
type LimiterIface interface { Key(c *gin.Context) string // 获取对应的限流器的键值对名称 GetBucket(key string) (*ratelimit.Bucket, bool) // 获取令牌桶 AddBuckets(rules ...LimiterBucketRule) LimiterIface // 新增多个令牌桶 }
func NewMethodLimiter ¶
func NewMethodLimiter() LimiterIface
type MethodLimiter ¶
type MethodLimiter struct {
*Limiter
}
func (MethodLimiter) AddBuckets ¶
func (m MethodLimiter) AddBuckets(rules ...LimiterBucketRule) LimiterIface
Click to show internal directories.
Click to hide internal directories.