Skip to content

Commit 270e7e0

Browse files
authored
Change the implementation of LoadRules in flow rule manager.go (alibaba#78)
* Change the implementation of LoadRules function in flow rule manager
1 parent 7c013e0 commit 270e7e0

File tree

1 file changed

+1
-23
lines changed

1 file changed

+1
-23
lines changed

core/flow/rule_manager.go

+1-23
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ package flow
33
import (
44
"encoding/json"
55
"fmt"
6-
"github.com/pkg/errors"
76
"github.com/alibaba/sentinel-golang/logging"
8-
"github.com/alibaba/sentinel-golang/util"
7+
"github.com/pkg/errors"
98
"sync"
109
)
1110

@@ -24,16 +23,9 @@ var (
2423
tcGenFuncMap = make(map[ControlBehavior]TrafficControllerGenFunc)
2524
tcMap = make(TrafficControllerMap, 0)
2625
tcMux = new(sync.RWMutex)
27-
28-
ruleChan = make(chan []*FlowRule, 10)
29-
propertyInit sync.Once
3026
)
3127

3228
func init() {
33-
propertyInit.Do(func() {
34-
initRuleRecvTask()
35-
})
36-
3729
// Initialize the traffic shaping controller generator map for existing control behaviors.
3830
tcGenFuncMap[Reject] = func(rule *FlowRule) *TrafficShapingController {
3931
return NewTrafficShapingController(NewDefaultTrafficShapingCalculator(rule.Count), NewDefaultTrafficShapingChecker(rule.MetricType), rule)
@@ -43,20 +35,6 @@ func init() {
4335
}
4436
}
4537

46-
func initRuleRecvTask() {
47-
go util.RunWithRecover(func() {
48-
for {
49-
select {
50-
case rules := <-ruleChan:
51-
err := onRuleUpdate(rules)
52-
if err != nil {
53-
logger.Errorf("Failed to update flow rules: %+v", err)
54-
}
55-
}
56-
}
57-
}, logger)
58-
}
59-
6038
func logRuleUpdate(m TrafficControllerMap) {
6139
bs, err := json.Marshal(rulesFrom(m))
6240
if err != nil {

0 commit comments

Comments
 (0)