Versions in this module Expand all Collapse all v0 v0.0.4 Sep 14, 2020 Changes in this version + const ConcurrencyMaxCount + const ParamsCapacityBase + const ParamsMaxCapacity + func ClearRules() error + func IsValidRule(rule *Rule) error + func LoadRules(rules []*Rule) (bool, error) + func RemoveTrafficShapingGenerator(cb ControlBehavior) error + func SetTrafficShapingGenerator(cb ControlBehavior, generator TrafficControllerGenFunc) error + type ConcurrencyStatSlot struct + func (c *ConcurrencyStatSlot) OnCompleted(ctx *base.EntryContext) + func (c *ConcurrencyStatSlot) OnEntryBlocked(ctx *base.EntryContext, blockError *base.BlockError) + func (c *ConcurrencyStatSlot) OnEntryPassed(ctx *base.EntryContext) + type ControlBehavior int8 + const Reject + const Throttling + func (t ControlBehavior) String() string + type MetricType int8 + const Concurrency + const QPS + func (t MetricType) String() string + type ParamKind int + const KindBool + const KindFloat64 + const KindInt + const KindString + const KindSum + func (t ParamKind) String() string + type ParamsMetric struct + ConcurrencyCounter cache.ConcurrentCounterCache + RuleTimeCounter cache.ConcurrentCounterCache + RuleTokenCounter cache.ConcurrentCounterCache + type Rule struct + BurstCount int64 + ControlBehavior ControlBehavior + DurationInSec int64 + ID string + MaxQueueingTimeMs int64 + MetricType MetricType + ParamIndex int + ParamsMaxCapacity int64 + Resource string + SpecificItems []SpecificValue + Threshold float64 + func GetRules(res string) []*Rule + func (r *Rule) Equals(newRule *Rule) bool + func (r *Rule) IsStatReusable(newRule *Rule) bool + func (r *Rule) ResourceName() string + func (r *Rule) String() string + type Slot struct + func (s *Slot) Check(ctx *base.EntryContext) *base.TokenResult + type SpecificValue struct + Threshold int64 + ValKind ParamKind + ValStr string + func (s *SpecificValue) String() string + type TrafficControllerGenFunc func(r *Rule, reuseMetric *ParamsMetric) TrafficShapingController + type TrafficShapingController interface + BoundMetric func() *ParamsMetric + BoundParamIndex func() int + BoundRule func() *Rule + PerformChecking func(arg interface{}, acquireCount int64) *base.TokenResult