Skip to content

Commit 64cf448

Browse files
authored
[bug-fix] probeNum参数更新,loadRule生效
[bug-fix] probeNum参数更新,loadRule生效
2 parents 7100e5b + 566193d commit 64cf448

File tree

3 files changed

+33
-7
lines changed

3 files changed

+33
-7
lines changed

core/circuitbreaker/rule.go

Lines changed: 8 additions & 6 deletions
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.
@@ -78,10 +78,10 @@ type Rule struct {
7878
// for ErrorRatio, it represents the max error request ratio
7979
// for ErrorCount, it represents the max error request count
8080
Threshold float64 `json:"threshold"`
81-
//ProbeNum is number of probes required when the circuit breaker is half-open.
82-
//when the probe num are set and circuit breaker in the half-open state.
83-
//if err occurs during the probe, the circuit breaker is opened immediately.
84-
//otherwise,the circuit breaker is closed only after the number of probes is reached
81+
// ProbeNum is number of probes required when the circuit breaker is half-open.
82+
// when the probe num are set and circuit breaker in the half-open state.
83+
// if err occurs during the probe, the circuit breaker is opened immediately.
84+
// otherwise,the circuit breaker is closed only after the number of probes is reached
8585
ProbeNum uint64 `json:"probeNum"`
8686
}
8787

@@ -103,12 +103,14 @@ func (r *Rule) ResourceName() string {
103103
return r.Resource
104104
}
105105

106+
// Check whether the fields shared by all rule strategy types are consistent
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.ProbeNum == newRule.ProbeNum
112114
}
113115

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

core/circuitbreaker/rule_test.go

Lines changed: 24 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy