Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FlowCounter ¶
type FlowCounter struct {
// contains filtered or unexported fields
}
计数器算法 FlowCounter
func NewFlowCounter ¶
func NewFlowCounter(counterLimit int, window int64) *FlowCounter
NewFlowCounter
func NewFlowCounterByParams ¶
func NewFlowCounterByParams(args ...interface{}) *FlowCounter
NewFlowCounterByParams
type FlowRollingCounter ¶
type FlowRollingCounter struct {
// contains filtered or unexported fields
}
计数器算法-滑动窗口 FlowRollingCounter
func NewFlowRollingCounter ¶
func NewFlowRollingCounter(counterLimit, subWinNums int, window int64) *FlowRollingCounter
NewFlowCounter counterLimit:总限制数量 subWinNums:子窗口个数 window:窗口大小 这个时间范围内请求个数不得超过counterLimit
func NewFlowRollingCounterByParams ¶
func NewFlowRollingCounterByParams(args ...interface{}) *FlowRollingCounter
NewFlowRollingCounterByParams
func (*FlowRollingCounter) Pass ¶
func (f *FlowRollingCounter) Pass() bool
Pass 是否达到限流 true 达到限流条件 false 还未达到限流
type LeakyBucket ¶
type LeakyBucket struct {
// contains filtered or unexported fields
}
漏桶算法
func NewLeakyBucket ¶
func NewLeakyBucket(counterLimit int, rate float32) *LeakyBucket
NewLeakyBucket
func NewLeakyBucketByParams ¶
func NewLeakyBucketByParams(args ...interface{}) *LeakyBucket
NewLeakyBucketByParams
type LimitFlowType ¶
type LimitFlowType string
LimitFlowType 限流算法
const ( LIMIT_FLOW_COUNTER LimitFlowType = "Counter" //计数器算法-固定窗口 LIMIT_FLOW_ROLLING_COUNTER LimitFlowType = "Rolling counter" //计数器算法-滑动窗口 LIMIT_FLOW_LEAKY_BUCKET LimitFlowType = "Leaky bucket" //漏桶算法 LIMIT_FLOW_TOKEN_BUCKET LimitFlowType = "Token bucket" //令牌桶 LIMIT_FLOW_NONE LimitFlowType = "None" //不限流 )
type TokenBucket ¶
type TokenBucket struct {
// contains filtered or unexported fields
}
令牌桶算法
func NewTokenBucketByParams ¶
func NewTokenBucketByParams(args ...interface{}) *TokenBucket
NewTokenBucketByParams
Click to show internal directories.
Click to hide internal directories.