Sentinel
Sentinel Golang
限流规则 # // Strategy type TokenCalculateStrategy int32 const ( Direct TokenCalculateStrategy = iota WarmUp MemoryAdaptive ) // Rule describes the strategy of flow control, the flow control strategy is based on QPS statistic metric type Rule struct { // ID represents the unique ID of the rule (optional). ID string `json:"id,omitempty"` // Resource represents the resource name. Resource string `json:"resource"` TokenCalculateStrategy TokenCalculateStrategy `json:"tokenCalculateStrategy"` ControlBehavior ControlBehavior `json:"controlBehavior"` // Threshold means the threshold during StatIntervalInMs // If StatIntervalInMs is 1000(1 second), Threshold means QPS Threshold float64 `json:"threshold"` RelationStrategy RelationStrategy `json:"relationStrategy"` RefResource string `json:"refResource"` // MaxQueueingTimeMs only takes effect when ControlBehavior is Throttling. // When MaxQueueingTimeMs is 0, it means Throttling only controls interval of requests, // and requests exceeding the threshold will be rejected directly. MaxQueueingTimeMs uint32 `json:"maxQueueingTimeMs"` WarmUpPeriodSec uint32 `json:"warmUpPeriodSec"` WarmUpColdFactor uint32 `json:"warmUpColdFactor"` // StatIntervalInMs indicates the statistic interval and it's the optional setting for flow Rule. // If user doesn't set StatIntervalInMs, that means using default metric statistic of resource. // If the StatIntervalInMs user specifies can not reuse the global statistic of resource, // sentinel will generate independent statistic structure for this rule. StatIntervalInMs uint32 `json:"statIntervalInMs"` // adaptive flow control algorithm related parameters // limitation: LowMemUsageThreshold > HighMemUsageThreshold && MemHighWaterMarkBytes > MemLowWaterMarkBytes // if the current memory usage is less than or equals to MemLowWaterMarkBytes, threshold == LowMemUsageThreshold // if the current memory usage is more than or equals to MemHighWaterMarkBytes, threshold == HighMemUsageThreshold // if the current memory usage is in (MemLowWaterMarkBytes, MemHighWaterMarkBytes), threshold is in (HighMemUsageThreshold, LowMemUsageThreshold) LowMemUsageThreshold int64 `json:"lowMemUsageThreshold"` HighMemUsageThreshold int64 `json:"highMemUsageThreshold"` MemLowWaterMarkBytes int64 `json:"memLowWaterMarkBytes"` MemHighWaterMarkBytes int64 `json:"memHighWaterMarkBytes"` } 熔断规则 # 熔断规则