Skip to content

Commit 5784a81

Browse files
caicai578223592
caicai
authored andcommitted
https://github.com/alibaba/sentinel-golang/issues/563
typo Trigger CI Signed-off-by: caicai <[email protected]> Trigger CI Signed-off-by: siwuxie <[email protected]>
1 parent 7100e5b commit 5784a81

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

core/circuitbreaker/rule.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ type Rule struct {
6161
// that can trigger circuit breaking.
6262
MinRequestAmount uint64 `json:"minRequestAmount"`
6363
// StatIntervalMs represents statistic time interval of the internal circuit breaker (in ms).
64-
// Currently the statistic interval is collected by sliding window.
64+
// Currently, the statistic interval is collected by sliding window.
6565
StatIntervalMs uint32 `json:"statIntervalMs"`
6666
// StatSlidingWindowBucketCount represents the bucket count of statistic sliding window.
6767
// 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 {
103103
return r.Resource
104104
}
105105

106+
// check whether the new rule is consistent with the old rule , it should compare every field except Rule.Id
106107
func (r *Rule) isEqualsToBase(newRule *Rule) bool {
107108
if newRule == nil {
108109
return false
109110
}
110111
return r.Resource == newRule.Resource && r.Strategy == newRule.Strategy && r.RetryTimeoutMs == newRule.RetryTimeoutMs &&
111-
r.MinRequestAmount == newRule.MinRequestAmount && r.StatIntervalMs == newRule.StatIntervalMs && r.StatSlidingWindowBucketCount == newRule.StatSlidingWindowBucketCount
112+
r.MinRequestAmount == newRule.MinRequestAmount && r.StatIntervalMs == newRule.StatIntervalMs && r.StatSlidingWindowBucketCount == newRule.StatSlidingWindowBucketCount &&
113+
r.MaxAllowedRtMs == newRule.MaxAllowedRtMs && r.Threshold == newRule.Threshold && r.ProbeNum == newRule.ProbeNum
112114
}
113115

114116
func (r *Rule) isEqualsTo(newRule *Rule) bool {

core/circuitbreaker/rule_test.go

+24
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,30 @@ func TestRuleIsEqualsToBase(t *testing.T) {
368368
},
369369
expectedResult: false,
370370
},
371+
// different ProbeNum
372+
{
373+
rule1: &Rule{
374+
Resource: "abc",
375+
Strategy: ErrorCount,
376+
RetryTimeoutMs: 3000,
377+
MinRequestAmount: 10,
378+
StatIntervalMs: 10000,
379+
StatSlidingWindowBucketCount: 2,
380+
Threshold: 1.0,
381+
ProbeNum: 10,
382+
},
383+
rule2: &Rule{
384+
Resource: "abc",
385+
Strategy: ErrorCount,
386+
RetryTimeoutMs: 3000,
387+
MinRequestAmount: 10,
388+
StatIntervalMs: 10000,
389+
StatSlidingWindowBucketCount: 2,
390+
Threshold: 1.0,
391+
ProbeNum: 11,
392+
},
393+
expectedResult: false,
394+
},
371395
}
372396

373397
for i, c := range cases {

core/hotspot/rule.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ type Rule struct {
7676
// ControlBehavior only takes effect when MetricType is QPS
7777
ControlBehavior ControlBehavior `json:"controlBehavior"`
7878
// ParamIndex is the index in context arguments slice.
79-
// if ParamIndex is great than or equals to zero, ParamIndex means the <ParamIndex>-th parameter
79+
// if ParamIndex is greater than or equals to zero, ParamIndex means the <ParamIndex>-th parameter
8080
// if ParamIndex is the negative, ParamIndex means the reversed <ParamIndex>-th parameter
8181
ParamIndex int `json:"paramIndex"`
8282
// ParamKey is the key in EntryContext.Input.Attachments map.

0 commit comments

Comments
 (0)