From 5784a81ee4e07a65a3ac6565c5f218e181aa53e7 Mon Sep 17 00:00:00 2001 From: caicai Date: Fri, 4 Oct 2024 22:39:16 +0800 Subject: [PATCH] https://github.com/alibaba/sentinel-golang/issues/563 typo Trigger CI Signed-off-by: caicai Trigger CI Signed-off-by: siwuxie --- core/circuitbreaker/rule.go | 6 ++++-- core/circuitbreaker/rule_test.go | 24 ++++++++++++++++++++++++ core/hotspot/rule.go | 2 +- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/core/circuitbreaker/rule.go b/core/circuitbreaker/rule.go index 0886604bc..5992dc5dd 100644 --- a/core/circuitbreaker/rule.go +++ b/core/circuitbreaker/rule.go @@ -61,7 +61,7 @@ type Rule struct { // that can trigger circuit breaking. MinRequestAmount uint64 `json:"minRequestAmount"` // StatIntervalMs represents statistic time interval of the internal circuit breaker (in ms). - // Currently the statistic interval is collected by sliding window. + // Currently, the statistic interval is collected by sliding window. StatIntervalMs uint32 `json:"statIntervalMs"` // StatSlidingWindowBucketCount represents the bucket count of statistic sliding window. // The statistic will be more precise as the bucket count increases, but the memory cost increases too. @@ -103,12 +103,14 @@ func (r *Rule) ResourceName() string { return r.Resource } +// check whether the new rule is consistent with the old rule , it should compare every field except Rule.Id func (r *Rule) isEqualsToBase(newRule *Rule) bool { if newRule == nil { return false } return r.Resource == newRule.Resource && r.Strategy == newRule.Strategy && r.RetryTimeoutMs == newRule.RetryTimeoutMs && - r.MinRequestAmount == newRule.MinRequestAmount && r.StatIntervalMs == newRule.StatIntervalMs && r.StatSlidingWindowBucketCount == newRule.StatSlidingWindowBucketCount + r.MinRequestAmount == newRule.MinRequestAmount && r.StatIntervalMs == newRule.StatIntervalMs && r.StatSlidingWindowBucketCount == newRule.StatSlidingWindowBucketCount && + r.MaxAllowedRtMs == newRule.MaxAllowedRtMs && r.Threshold == newRule.Threshold && r.ProbeNum == newRule.ProbeNum } func (r *Rule) isEqualsTo(newRule *Rule) bool { diff --git a/core/circuitbreaker/rule_test.go b/core/circuitbreaker/rule_test.go index 604ed2674..7f34b4e99 100644 --- a/core/circuitbreaker/rule_test.go +++ b/core/circuitbreaker/rule_test.go @@ -368,6 +368,30 @@ func TestRuleIsEqualsToBase(t *testing.T) { }, expectedResult: false, }, + // different ProbeNum + { + rule1: &Rule{ + Resource: "abc", + Strategy: ErrorCount, + RetryTimeoutMs: 3000, + MinRequestAmount: 10, + StatIntervalMs: 10000, + StatSlidingWindowBucketCount: 2, + Threshold: 1.0, + ProbeNum: 10, + }, + rule2: &Rule{ + Resource: "abc", + Strategy: ErrorCount, + RetryTimeoutMs: 3000, + MinRequestAmount: 10, + StatIntervalMs: 10000, + StatSlidingWindowBucketCount: 2, + Threshold: 1.0, + ProbeNum: 11, + }, + expectedResult: false, + }, } for i, c := range cases { diff --git a/core/hotspot/rule.go b/core/hotspot/rule.go index 678541042..b46f5fdfb 100644 --- a/core/hotspot/rule.go +++ b/core/hotspot/rule.go @@ -76,7 +76,7 @@ type Rule struct { // ControlBehavior only takes effect when MetricType is QPS ControlBehavior ControlBehavior `json:"controlBehavior"` // ParamIndex is the index in context arguments slice. - // if ParamIndex is great than or equals to zero, ParamIndex means the -th parameter + // if ParamIndex is greater than or equals to zero, ParamIndex means the -th parameter // if ParamIndex is the negative, ParamIndex means the reversed -th parameter ParamIndex int `json:"paramIndex"` // ParamKey is the key in EntryContext.Input.Attachments map.