ratelimiter

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 18, 2021 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 3 more Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AmountDuration

type AmountDuration struct {
	AmountUsed    uint32
	ValidDuration time.Duration
}

单个配额

type InitCriteria

type InitCriteria struct {
	DstRule *namingpb.Rule
}

配额查询相关的信息

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

func (*Proxy) SetRealPlugin

func (p *Proxy) SetRealPlugin(plug plugin.Plugin, engine model.Engine)

设置

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)
}

服务限流处理插件接口

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL