File tree 3 files changed +29
-3
lines changed
3 files changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ type Rule struct {
61
61
// that can trigger circuit breaking.
62
62
MinRequestAmount uint64 `json:"minRequestAmount"`
63
63
// 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.
65
65
StatIntervalMs uint32 `json:"statIntervalMs"`
66
66
// StatSlidingWindowBucketCount represents the bucket count of statistic sliding window.
67
67
// 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 {
103
103
return r .Resource
104
104
}
105
105
106
+ // check whether the new rule is consistent with the old rule , it should compare every field except Rule.Id
106
107
func (r * Rule ) isEqualsToBase (newRule * Rule ) bool {
107
108
if newRule == nil {
108
109
return false
109
110
}
110
111
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
112
114
}
113
115
114
116
func (r * Rule ) isEqualsTo (newRule * Rule ) bool {
Original file line number Diff line number Diff line change @@ -368,6 +368,30 @@ func TestRuleIsEqualsToBase(t *testing.T) {
368
368
},
369
369
expectedResult : false ,
370
370
},
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
+ },
371
395
}
372
396
373
397
for i , c := range cases {
Original file line number Diff line number Diff line change @@ -76,7 +76,7 @@ type Rule struct {
76
76
// ControlBehavior only takes effect when MetricType is QPS
77
77
ControlBehavior ControlBehavior `json:"controlBehavior"`
78
78
// 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
80
80
// if ParamIndex is the negative, ParamIndex means the reversed <ParamIndex>-th parameter
81
81
ParamIndex int `json:"paramIndex"`
82
82
// ParamKey is the key in EntryContext.Input.Attachments map.
You can’t perform that action at this time.
0 commit comments