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