Documentation ¶
Overview ¶
Package system provides implementation of adaptive system protection.
Index ¶
Constants ¶
View Source
const (
RuleCheckSlotOrder = 1000
)
Variables ¶
View Source
var (
DefaultAdaptiveSlot = &AdaptiveSlot{}
)
Functions ¶
func IsValidSystemRule ¶
IsValidSystemRule determine the system rule is valid or not
Types ¶
type AdaptiveSlot ¶
type AdaptiveSlot struct { }
func (*AdaptiveSlot) Check ¶
func (s *AdaptiveSlot) Check(ctx *base.EntryContext) *base.TokenResult
func (*AdaptiveSlot) Order ¶
func (s *AdaptiveSlot) Order() uint32
type AdaptiveStrategy ¶
type AdaptiveStrategy int32
const ( NoAdaptive AdaptiveStrategy = -1 // BBR represents the adaptive strategy based on ideas of TCP BBR. BBR AdaptiveStrategy = iota )
func (AdaptiveStrategy) String ¶
func (t AdaptiveStrategy) String() string
type MetricType ¶
type MetricType uint32
const ( // Load represents system load1 in Linux/Unix. Load MetricType = iota // AvgRT represents the average response time of all inbound requests. AvgRT // Concurrency represents the concurrency of all inbound requests. Concurrency // InboundQPS represents the QPS of all inbound requests. InboundQPS // CpuUsage represents the CPU usage percentage of the system. CpuUsage // MetricTypeSize indicates the enum size of MetricType. MetricTypeSize )
func (MetricType) String ¶
func (t MetricType) String() string
type Rule ¶
type Rule struct { // ID represents the unique ID of the rule (optional). ID string `json:"id,omitempty"` // MetricType indicates the type of the trigger metric. MetricType MetricType `json:"metricType"` // TriggerCount represents the lower bound trigger of the adaptive strategy. // Adaptive strategies will not be activated until target metric has reached the trigger count. TriggerCount float64 `json:"triggerCount"` // Strategy represents the adaptive strategy. Strategy AdaptiveStrategy `json:"strategy"` }
Rule describes the policy for system resiliency.
func GetRules ¶
func GetRules() []Rule
GetRules returns all the rules based on copy. It doesn't take effect for system module if user changes the rule. GetRules need to compete system module's global lock and the high performance losses of copy,
reduce or do not call GetRules if possible
func (*Rule) ResourceName ¶
type RuleMap ¶
type RuleMap map[MetricType][]*Rule
Click to show internal directories.
Click to hide internal directories.