Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AmountDuration ¶
AmountDuration 单个配额
type AmountInfo ¶ added in v1.2.0
type InitCriteria ¶
InitCriteria 配额查询相关的信息
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
InitQuota proxy ServiceRateLimiter InitQuota
type QuotaBucket ¶
type QuotaBucket interface { // GetQuota 在令牌桶/漏桶中进行单个配额的划扣,并返回本次分配的结果 GetQuota(curTimeMs int64, token uint32) *model.QuotaResponse // Release 释放配额(仅对于并发数限流有用) Release() // OnRemoteUpdate 远程配额更新 OnRemoteUpdate(RemoteQuotaResult) // GetQuotaUsed 拉取本地使用配额情况以供上报 GetQuotaUsed(curTimeMilli int64) UsageInfo // GetAmountInfos 获取规则的限流阈值信息 GetAmountInfos() []AmountInfo }
QuotaBucket 配额池
type RemoteQuotaResult ¶ added in v1.2.0
type RemoteQuotaResult struct { Left int64 ClientCount uint32 ServerTimeMilli int64 DurationMill int64 ClientTimeMilli int64 }
RemoteQuotaResult 远程下发配额
type ServiceRateLimiter ¶
type ServiceRateLimiter interface { plugin.Plugin // InitQuota 初始化并创建令牌桶/漏桶 // 主流程会在首次调用,以及规则对象变更的时候,调用该方法 InitQuota(criteria *InitCriteria) QuotaBucket }
ServiceRateLimiter 服务限流处理插件接口
Click to show internal directories.
Click to hide internal directories.