Documentation ¶
Index ¶
- type BucketShareInfo
- type QuotaBucketReject
- func (q *QuotaBucketReject) GetAmountInfos() []ratelimiter.AmountInfo
- func (q *QuotaBucketReject) GetQuota(curTimeMs int64, token uint32) *model.QuotaResponse
- func (q *QuotaBucketReject) GetQuotaUsed(curTimeMilli int64) ratelimiter.UsageInfo
- func (q *QuotaBucketReject) OnRemoteUpdate(remoteQuota ratelimiter.RemoteQuotaResult)
- func (q *QuotaBucketReject) Release()
- type RateLimiterReject
- func (g *RateLimiterReject) Destroy() error
- func (g *RateLimiterReject) Init(ctx *plugin.InitContext) error
- func (g *RateLimiterReject) InitQuota(criteria *ratelimiter.InitCriteria) ratelimiter.QuotaBucket
- func (g *RateLimiterReject) IsEnable(cfg config.Configuration) bool
- func (g *RateLimiterReject) Name() string
- func (g *RateLimiterReject) Type() common.Type
- type RemoteAwareQpsBucket
- func (r *RemoteAwareQpsBucket) Allocate(curTimeMs int64, token uint32) *model.QuotaResponse
- func (r *RemoteAwareQpsBucket) GetQuotaUsed(serverTimeMilli int64) ratelimiter.UsageInfo
- func (r *RemoteAwareQpsBucket) GetTokenBuckets() TokenBuckets
- func (r *RemoteAwareQpsBucket) Release()
- func (r *RemoteAwareQpsBucket) SetRemoteQuota(remoteQuotas ratelimiter.RemoteQuotaResult)
- type TokenBucket
- func (t *TokenBucket) ConfirmLimited(limited uint32, nowMilli int64)
- func (t *TokenBucket) ConfirmPassed(passed uint32, nowMilli int64)
- func (t *TokenBucket) GetRuleTotal() int64
- func (t *TokenBucket) GiveBackToken(identifier *UpdateIdentifier, token int64, mode TokenBucketMode)
- func (t *TokenBucket) TryAllocateToken(token uint32, nowMilli int64, identifier *UpdateIdentifier, ...) (int64, TokenBucketMode)
- func (t *TokenBucket) UpdateRemoteClientCount(remoteQuotas ratelimiter.RemoteQuotaResult)
- func (t *TokenBucket) UpdateRemoteToken(remoteQuotas ratelimiter.RemoteQuotaResult, updateClient bool)
- type TokenBucketMode
- type TokenBuckets
- type UpdateIdentifier
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BucketShareInfo ¶
type BucketShareInfo struct {
// contains filtered or unexported fields
}
BucketShareInfo 通用信息
type QuotaBucketReject ¶
type QuotaBucketReject struct {
// contains filtered or unexported fields
}
func (*QuotaBucketReject) GetAmountInfos ¶
func (q *QuotaBucketReject) GetAmountInfos() []ratelimiter.AmountInfo
GetAmountInfos 获取规则的限流阈值信息
func (*QuotaBucketReject) GetQuota ¶
func (q *QuotaBucketReject) GetQuota(curTimeMs int64, token uint32) *model.QuotaResponse
GetQuota 在令牌桶/漏桶中进行单个配额的划扣,并返回本次分配的结果
func (*QuotaBucketReject) GetQuotaUsed ¶
func (q *QuotaBucketReject) GetQuotaUsed(curTimeMilli int64) ratelimiter.UsageInfo
GetQuotaUsed 拉取本地使用配额情况以供上报
func (*QuotaBucketReject) OnRemoteUpdate ¶
func (q *QuotaBucketReject) OnRemoteUpdate(remoteQuota ratelimiter.RemoteQuotaResult)
OnRemoteUpdate 远程配额更新
type RateLimiterReject ¶
type RateLimiterReject struct {
*plugin.PluginBase
}
RateLimiterReject 基于直接拒绝策略的限流控制器
func (*RateLimiterReject) Destroy ¶
func (g *RateLimiterReject) Destroy() error
Destroy 销毁插件,可用于释放资源
func (*RateLimiterReject) Init ¶
func (g *RateLimiterReject) Init(ctx *plugin.InitContext) error
Init 初始化插件
func (*RateLimiterReject) InitQuota ¶
func (g *RateLimiterReject) InitQuota(criteria *ratelimiter.InitCriteria) ratelimiter.QuotaBucket
InitQuota 初始化并创建限流窗口 主流程会在首次调用,以及规则对象变更的时候,调用该方法
func (*RateLimiterReject) IsEnable ¶
func (g *RateLimiterReject) IsEnable(cfg config.Configuration) bool
IsEnable enable
type RemoteAwareQpsBucket ¶
type RemoteAwareQpsBucket struct {
// contains filtered or unexported fields
}
RemoteAwareQpsBucket 远程配额分配的算法桶
func NewRemoteAwareQpsBucket ¶
func NewRemoteAwareQpsBucket(criteria *ratelimiter.InitCriteria) *RemoteAwareQpsBucket
NewRemoteAwareQpsBucket 创建QPS远程限流窗口
func (*RemoteAwareQpsBucket) Allocate ¶
func (r *RemoteAwareQpsBucket) Allocate(curTimeMs int64, token uint32) *model.QuotaResponse
Allocate 执行配额分配操作
func (*RemoteAwareQpsBucket) GetQuotaUsed ¶
func (r *RemoteAwareQpsBucket) GetQuotaUsed(serverTimeMilli int64) ratelimiter.UsageInfo
func (*RemoteAwareQpsBucket) GetTokenBuckets ¶
func (r *RemoteAwareQpsBucket) GetTokenBuckets() TokenBuckets
func (*RemoteAwareQpsBucket) SetRemoteQuota ¶
func (r *RemoteAwareQpsBucket) SetRemoteQuota(remoteQuotas ratelimiter.RemoteQuotaResult)
SetRemoteQuota 设置通过限流服务端获取的远程QPS
type TokenBucket ¶
type TokenBucket struct { UpdateIdentifier // contains filtered or unexported fields }
TokenBucket 令牌桶
func NewTokenBucket ¶
func NewTokenBucket( windowKey string, validDuration time.Duration, tokenAmount uint32, shareInfo *BucketShareInfo) *TokenBucket
NewTokenBucket 创建令牌桶
func (*TokenBucket) ConfirmLimited ¶
func (t *TokenBucket) ConfirmLimited(limited uint32, nowMilli int64)
ConfirmLimited 记录限流分配配额
func (*TokenBucket) ConfirmPassed ¶
func (t *TokenBucket) ConfirmPassed(passed uint32, nowMilli int64)
ConfirmPassed 记录真实分配配额
func (*TokenBucket) GiveBackToken ¶
func (t *TokenBucket) GiveBackToken(identifier *UpdateIdentifier, token int64, mode TokenBucketMode)
GiveBackToken 归还配额
func (*TokenBucket) TryAllocateToken ¶
func (t *TokenBucket) TryAllocateToken( token uint32, nowMilli int64, identifier *UpdateIdentifier, mode TokenBucketMode) (int64, TokenBucketMode)
TryAllocateToken 尝试分配配额
func (*TokenBucket) UpdateRemoteClientCount ¶
func (t *TokenBucket) UpdateRemoteClientCount(remoteQuotas ratelimiter.RemoteQuotaResult)
UpdateRemoteClientCount 只更新远程客户端数量,不更新配额
func (*TokenBucket) UpdateRemoteToken ¶
func (t *TokenBucket) UpdateRemoteToken(remoteQuotas ratelimiter.RemoteQuotaResult, updateClient bool)
UpdateRemoteToken 更新远程配额
type TokenBucketMode ¶
type TokenBucketMode int
const ( Unknown TokenBucketMode = iota Remote RemoteToLocal Local )
type UpdateIdentifier ¶
type UpdateIdentifier struct {
// contains filtered or unexported fields
}
UpdateIdentifier 令牌桶是否进行更新的凭证
Click to show internal directories.
Click to hide internal directories.