Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AmountDuration ¶
AmountDuration 单个配额
type Proxy ¶
type Proxy struct { ServiceRateLimiter // contains filtered or unexported fields }
Proxy is a proxy plugin for rate-limiter
func (*Proxy) InitQuota ¶
func (p *Proxy) InitQuota(criteria *InitCriteria) (QuotaBucket, error)
InitQuota proxy ServiceRateLimiter InitQuota
type QuotaBucket ¶
type QuotaBucket interface { // GetQuota 在令牌桶/漏桶中进行单个配额的划扣,并返回本次分配的结果 GetQuota() (*QuotaResult, error) // Release 释放配额(仅对于并发数限流有用) Release() }
QuotaBucket 配额池
type QuotaResult ¶
type QuotaResult struct { // 分配的结果码 Code model.QuotaResultCode // 分配的提示信息 Info string // 排队时间,标识多长时间后可以有新配额供应 QueueTime time.Duration }
QuotaResult 配额分配的结果
type ServiceRateLimiter ¶
type ServiceRateLimiter interface { plugin.Plugin // 初始化并创建令牌桶/漏桶 // 主流程会在首次调用,以及规则对象变更的时候,调用该方法 InitQuota(criteria *InitCriteria) (QuotaBucket, error) }
ServiceRateLimiter 服务限流处理插件接口
Click to show internal directories.
Click to hide internal directories.