Repository: alibaba/sentinel-golang
Pull request #221 (2020-09-03 12:13:38)

Refine flow module code

### Describe what this PR does / why we need it
1.  remove cluster flow control code related.
2. rename flow.FlowRule to flow.Rule

### Does this pull request fix one issue?

<!--If that, add "Fixes #xxxx" below in the next line. For example, Fixes #15. Otherwise, add "NONE" -->

### Describe how you did it


### Describe how to verify it


### Special notes for reviews

codecov-commenter: # [Codecov](https://codecov.io/gh/alibaba/sentinel-golang/pull/221?src=pr&el=h1) Report
> Merging [#221](https://codecov.io/gh/alibaba/sentinel-golang/pull/221?src=pr&el=desc) into [master](https://codecov.io/gh/alibaba/sentinel-golang/commit/e61cf47f58e6ad2b0bd4759f8f2a2c6345ff6ee2?el=desc) will **decrease** coverage by `0.06%`.
> The diff coverage is `52.00%`.

[![Impacted file tree graph](https://codecov.io/gh/alibaba/sentinel-golang/pull/221/graphs/tree.svg?width=650&height=150&src=pr&token=SrpzbhKA3E)](https://codecov.io/gh/alibaba/sentinel-golang/pull/221?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master     #221      +/-   ##
==========================================
- Coverage   42.63%   42.56%   -0.07%     
==========================================
  Files          84       84              
  Lines        4492     4485       -7     
==========================================
- Hits         1915     1909       -6     
+ Misses       2334     2333       -1     
  Partials      243      243              
```


| [Impacted Files](https://codecov.io/gh/alibaba/sentinel-golang/pull/221?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [core/flow/rule.go](https://codecov.io/gh/alibaba/sentinel-golang/pull/221/diff?src=pr&el=tree#diff-Y29yZS9mbG93L3J1bGUuZ28=) | `0.00% <0.00%> (ø)` | |
| [core/flow/slot.go](https://codecov.io/gh/alibaba/sentinel-golang/pull/221/diff?src=pr&el=tree#diff-Y29yZS9mbG93L3Nsb3QuZ28=) | `0.00% <0.00%> (ø)` | |
| [core/flow/tc\_default.go](https://codecov.io/gh/alibaba/sentinel-golang/pull/221/diff?src=pr&el=tree#diff-Y29yZS9mbG93L3RjX2RlZmF1bHQuZ28=) | `0.00% <0.00%> (ø)` | |
| [core/flow/tc\_warm\_up.go](https://codecov.io/gh/alibaba/sentinel-golang/pull/221/diff?src=pr&el=tree#diff-Y29yZS9mbG93L3RjX3dhcm1fdXAuZ28=) | `0.00% <0.00%> (ø)` | |
| [core/flow/rule\_manager.go](https://codecov.io/gh/alibaba/sentinel-golang/pull/221/diff?src=pr&el=tree#diff-Y29yZS9mbG93L3J1bGVfbWFuYWdlci5nbw==) | `51.58% <58.33%> (-2.21%)` | :arrow_down: |
| [ext/datasource/helper.go](https://codecov.io/gh/alibaba/sentinel-golang/pull/221/diff?src=pr&el=tree#diff-ZXh0L2RhdGFzb3VyY2UvaGVscGVyLmdv) | `57.65% <80.00%> (ø)` | |
| [core/flow/traffic\_shaping.go](https://codecov.io/gh/alibaba/sentinel-golang/pull/221/diff?src=pr&el=tree#diff-Y29yZS9mbG93L3RyYWZmaWNfc2hhcGluZy5nbw==) | `36.36% <100.00%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/alibaba/sentinel-golang/pull/221?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/alibaba/sentinel-golang/pull/221?src=pr&el=footer). Last update [e61cf47...0da4877](https://codecov.io/gh/alibaba/sentinel-golang/pull/221?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/core/flow/rule.go b/core/flow/rule.go
index 6c2e147..8ff96b4 100644
--- a/core/flow/rule.go
+++ b/core/flow/rule.go
@@ -44,19 +44,8 @@ const (
 	WarmUpThrottling
 )
 
-type ClusterThresholdMode uint32
-
-const (
-	AvgLocalThreshold ClusterThresholdMode = iota
-	GlobalThreshold
-)
-
-type ClusterRuleConfig struct {
-	ThresholdType ClusterThresholdMode `json:"thresholdType"`
-}
-
-// FlowRule describes the strategy of flow control.
-type FlowRule struct {
+// Rule describes the strategy of flow control.
+type Rule struct {
 	// ID represents the unique ID of the rule (optional).
 	ID uint64 `json:"id,omitempty"`
 
@@ -71,24 +60,21 @@ type FlowRule struct {
 	ControlBehavior  ControlBehavior  `json:"controlBehavior"`
 
 	RefResource       string `json:"refResource"`
-	WarmUpPeriodSec   uint32 `json:"warmUpPeriodSec"`
 	MaxQueueingTimeMs uint32 `json:"maxQueueingTimeMs"`
-	// ClusterMode indicates whether the rule is for cluster flow control or local.
-	ClusterMode      bool              `json:"clusterMode"`
-	ClusterConfig    ClusterRuleConfig `json:"clusterConfig"`
-	WarmUpColdFactor uint32            `json:"warmUpColdFactor"`
+	WarmUpPeriodSec   uint32 `json:"warmUpPeriodSec"`
+	WarmUpColdFactor  uint32 `json:"warmUpColdFactor"`
 }
 
-func (f *FlowRule) String() string {
+func (f *Rule) String() string {
 	b, err := json.Marshal(f)
 	if err != nil {
 		// Return the fallback string
-		return fmt.Sprintf("FlowRule{resource=%s, id=%d, metricType=%d, threshold=%.2f}",
+		return fmt.Sprintf("Rule{resource=%s, id=%d, metricType=%d, threshold=%.2f}",
 			f.Resource, f.ID, f.MetricType, f.Count)
 	}
 	return string(b)
 }
 
-func (f *FlowRule) ResourceName() string {
+func (f *Rule) ResourceName() string {
 	return f.Resource
 }
diff --git a/core/flow/rule_manager.go b/core/flow/rule_manager.go
index ec73706..603865d 100644
--- a/core/flow/rule_manager.go
+++ b/core/flow/rule_manager.go
@@ -11,7 +11,7 @@ import (
 )
 
 // TrafficControllerGenFunc represents the TrafficShapingController generator function of a specific control behavior.
-type TrafficControllerGenFunc func(*FlowRule) *TrafficShapingController
+type TrafficControllerGenFunc func(*Rule) *TrafficShapingController
 
 // TrafficControllerMap represents the map storage for TrafficShapingController.
 type TrafficControllerMap map[string][]*TrafficShapingController
@@ -24,13 +24,13 @@ var (
 
 func init() {
 	// Initialize the traffic shaping controller generator map for existing control behaviors.
-	tcGenFuncMap[Reject] = func(rule *FlowRule) *TrafficShapingController {
+	tcGenFuncMap[Reject] = func(rule *Rule) *TrafficShapingController {
 		return NewTrafficShapingController(NewDefaultTrafficShapingCalculator(rule.Count), NewDefaultTrafficShapingChecker(rule), rule)
 	}
-	tcGenFuncMap[Throttling] = func(rule *FlowRule) *TrafficShapingController {
+	tcGenFuncMap[Throttling] = func(rule *Rule) *TrafficShapingController {
 		return NewTrafficShapingController(NewDefaultTrafficShapingCalculator(rule.Count), NewThrottlingChecker(rule.MaxQueueingTimeMs), rule)
 	}
-	tcGenFuncMap[WarmUp] = func(rule *FlowRule) *TrafficShapingController {
+	tcGenFuncMap[WarmUp] = func(rule *Rule) *TrafficShapingController {
 		return NewTrafficShapingController(NewWarmUpTrafficShapingCalculator(rule), NewDefaultTrafficShapingChecker(rule), rule)
 	}
 }
@@ -44,7 +44,7 @@ func logRuleUpdate(m TrafficControllerMap) {
 	}
 }
 
-func onRuleUpdate(rules []*FlowRule) (err error) {
+func onRuleUpdate(rules []*Rule) (err error) {
 	defer func() {
 		if r := recover(); r != nil {
 			var ok bool
@@ -73,13 +73,13 @@ func onRuleUpdate(rules []*FlowRule) (err error) {
 }
 
 // LoadRules loads the given flow rules to the rule manager, while all previous rules will be replaced.
-func LoadRules(rules []*FlowRule) (bool, error) {
+func LoadRules(rules []*Rule) (bool, error) {
 	// TODO: rethink the design
 	err := onRuleUpdate(rules)
 	return true, err
 }
 
-func GetRules() []*FlowRule {
+func GetRules() []*Rule {
 	tcMux.RLock()
 	defer tcMux.RUnlock()
 
@@ -91,8 +91,8 @@ func ClearRules() error {
 	return err
 }
 
-func rulesFrom(m TrafficControllerMap) []*FlowRule {
-	rules := make([]*FlowRule, 0)
+func rulesFrom(m TrafficControllerMap) []*Rule {
+	rules := make([]*Rule, 0)
 	if len(m) == 0 {
 		return rules
 	}
@@ -144,7 +144,7 @@ func getTrafficControllerListFor(name string) []*TrafficShapingController {
 }
 
 // NotThreadSafe (should be guarded by the lock)
-func buildFlowMap(rules []*FlowRule) TrafficControllerMap {
+func buildFlowMap(rules []*Rule) TrafficControllerMap {
 	m := make(TrafficControllerMap)
 	if len(rules) == 0 {
 		return m
@@ -179,10 +179,10 @@ func buildFlowMap(rules []*FlowRule) TrafficControllerMap {
 	return m
 }
 
-// IsValidFlowRule checks whether the given FlowRule is valid.
-func IsValidFlowRule(rule *FlowRule) error {
+// IsValidFlowRule checks whether the given Rule is valid.
+func IsValidFlowRule(rule *Rule) error {
 	if rule == nil {
-		return errors.New("nil FlowRule")
+		return errors.New("nil Rule")
 	}
 	if rule.Resource == "" {
 		return errors.New("empty resource name")
@@ -203,21 +203,11 @@ func IsValidFlowRule(rule *FlowRule) error {
 	if rule.RelationStrategy == AssociatedResource && rule.RefResource == "" {
 		return errors.New("Bad flow rule: invalid control behavior")
 	}
-	if err := checkClusterField(rule); err != nil {
-		return err
-	}
 
 	return checkControlBehaviorField(rule)
 }
 
-func checkClusterField(rule *FlowRule) error {
-	if rule.ClusterMode && rule.ID <= 0 {
-		return errors.New("invalid cluster rule ID")
-	}
-	return nil
-}
-
-func checkControlBehaviorField(rule *FlowRule) error {
+func checkControlBehaviorField(rule *Rule) error {
 	switch rule.ControlBehavior {
 	case WarmUp:
 		if rule.WarmUpPeriodSec <= 0 {
diff --git a/core/flow/slot.go b/core/flow/slot.go
index 36ab452..281c8c6 100644
--- a/core/flow/slot.go
+++ b/core/flow/slot.go
@@ -50,13 +50,10 @@ func canPassCheck(tc *TrafficShapingController, node base.StatNode, acquireCount
 }
 
 func canPassCheckWithFlag(tc *TrafficShapingController, node base.StatNode, acquireCount uint32, flag int32) *base.TokenResult {
-	if tc.rule.ClusterMode {
-		// TODO: support cluster mode
-	}
 	return checkInLocal(tc, node, acquireCount, flag)
 }
 
-func selectNodeByRelStrategy(rule *FlowRule, node base.StatNode) base.StatNode {
+func selectNodeByRelStrategy(rule *Rule, node base.StatNode) base.StatNode {
 	if rule.RelationStrategy == AssociatedResource {
 		return stat.GetResourceNode(rule.RefResource)
 	}
diff --git a/core/flow/tc_default.go b/core/flow/tc_default.go
index 2980e87..c767e69 100644
--- a/core/flow/tc_default.go
+++ b/core/flow/tc_default.go
@@ -17,10 +17,10 @@ func (d *DefaultTrafficShapingCalculator) CalculateAllowedTokens(base.StatNode,
 }
 
 type DefaultTrafficShapingChecker struct {
-	rule *FlowRule
+	rule *Rule
 }
 
-func NewDefaultTrafficShapingChecker(rule *FlowRule) *DefaultTrafficShapingChecker {
+func NewDefaultTrafficShapingChecker(rule *Rule) *DefaultTrafficShapingChecker {
 	return &DefaultTrafficShapingChecker{rule: rule}
 }
 
diff --git a/core/flow/tc_warm_up.go b/core/flow/tc_warm_up.go
index 63841cf..da4fe41 100644
--- a/core/flow/tc_warm_up.go
+++ b/core/flow/tc_warm_up.go
@@ -22,7 +22,7 @@ type WarmUpTrafficShapingCalculator struct {
 	lastFilledTime    uint64
 }
 
-func NewWarmUpTrafficShapingCalculator(rule *FlowRule) *WarmUpTrafficShapingCalculator {
+func NewWarmUpTrafficShapingCalculator(rule *Rule) *WarmUpTrafficShapingCalculator {
 	if rule.WarmUpColdFactor <= 1 {
 		rule.WarmUpColdFactor = config.DefaultWarmUpColdFactor
 		logging.Warnf("[NewWarmUpTrafficShapingCalculator] invalid WarmUpColdFactor,use default values: %d", config.DefaultWarmUpColdFactor)
diff --git a/core/flow/traffic_shaping.go b/core/flow/traffic_shaping.go
index c558abd..52b06df 100644
--- a/core/flow/traffic_shaping.go
+++ b/core/flow/traffic_shaping.go
@@ -20,15 +20,15 @@ type TrafficShapingController struct {
 	flowCalculator TrafficShapingCalculator
 	flowChecker    TrafficShapingChecker
 
-	rule *FlowRule
+	rule *Rule
 }
 
 // NewTrafficShapingController creates a TrafficShapingController wrapped with the given checker and flow rule.
-func NewTrafficShapingController(flowCalculator TrafficShapingCalculator, flowChecker TrafficShapingChecker, rule *FlowRule) *TrafficShapingController {
+func NewTrafficShapingController(flowCalculator TrafficShapingCalculator, flowChecker TrafficShapingChecker, rule *Rule) *TrafficShapingController {
 	return &TrafficShapingController{flowCalculator: flowCalculator, flowChecker: flowChecker, rule: rule}
 }
 
-func (t *TrafficShapingController) Rule() *FlowRule {
+func (t *TrafficShapingController) Rule() *Rule {
 	return t.rule
 }
 
diff --git a/example/qps/qps_limit_example.go b/example/qps/qps_limit_example.go
index 4760d61..e7d5270 100644
--- a/example/qps/qps_limit_example.go
+++ b/example/qps/qps_limit_example.go
@@ -19,7 +19,7 @@ func main() {
 		log.Fatalf("Unexpected error: %+v", err)
 	}
 
-	_, err = flow.LoadRules([]*flow.FlowRule{
+	_, err = flow.LoadRules([]*flow.Rule{
 		{
 			Resource:        "some-test",
 			MetricType:      flow.QPS,
diff --git a/example/warm_up/qps_warm_up_example.go b/example/warm_up/qps_warm_up_example.go
index 824e741..0f5563a 100644
--- a/example/warm_up/qps_warm_up_example.go
+++ b/example/warm_up/qps_warm_up_example.go
@@ -31,7 +31,7 @@ func main() {
 		log.Fatalf("Unexpected error: %+v", err)
 	}
 
-	_, err = flow.LoadRules([]*flow.FlowRule{
+	_, err = flow.LoadRules([]*flow.Rule{
 		{
 			Resource:         "some-test",
 			MetricType:       flow.QPS,
diff --git a/ext/datasource/helper.go b/ext/datasource/helper.go
index 397ebad..daf96e9 100644
--- a/ext/datasource/helper.go
+++ b/ext/datasource/helper.go
@@ -17,34 +17,34 @@ func checkSrcComplianceJson(src []byte) (bool, error) {
 	return true, nil
 }
 
-// FlowRuleJsonArrayParser provide JSON  as the default serialization for list of flow.FlowRule
+// FlowRuleJsonArrayParser provide JSON  as the default serialization for list of flow.Rule
 func FlowRuleJsonArrayParser(src []byte) (interface{}, error) {
 	if valid, err := checkSrcComplianceJson(src); !valid {
 		return nil, err
 	}
 
-	rules := make([]*flow.FlowRule, 0)
+	rules := make([]*flow.Rule, 0)
 	err := json.Unmarshal(src, &rules)
 	return rules, err
 }
 
-// FlowRulesUpdater load the newest []flow.FlowRule to downstream flow component.
+// FlowRulesUpdater load the newest []flow.Rule to downstream flow component.
 func FlowRulesUpdater(data interface{}) error {
 	if data == nil {
 		return flow.ClearRules()
 	}
 
-	rules := make([]*flow.FlowRule, 0)
-	if val, ok := data.([]flow.FlowRule); ok {
+	rules := make([]*flow.Rule, 0)
+	if val, ok := data.([]flow.Rule); ok {
 		for _, v := range val {
 			rules = append(rules, &v)
 		}
-	} else if val, ok := data.([]*flow.FlowRule); ok {
+	} else if val, ok := data.([]*flow.Rule); ok {
 		rules = val
 	} else {
 		return Error{
 			code: UpdatePropertyError,
-			desc: fmt.Sprintf("Fail to type assert data to []flow.FlowRule or []*flow.FlowRule, in fact, data: %+v", data),
+			desc: fmt.Sprintf("Fail to type assert data to []flow.Rule or []*flow.Rule, in fact, data: %+v", data),
 		}
 	}
 	succ, err := flow.LoadRules(rules)


Test patch:
diff --git a/adapter/echo/middleware_test.go b/adapter/echo/middleware_test.go
index 976ef61..686f0bf 100644
--- a/adapter/echo/middleware_test.go
+++ b/adapter/echo/middleware_test.go
@@ -18,7 +18,7 @@ func initSentinel(t *testing.T) {
 		t.Fatalf("Unexpected error: %+v", err)
 	}
 
-	_, err = flow.LoadRules([]*flow.FlowRule{
+	_, err = flow.LoadRules([]*flow.Rule{
 		{
 			Resource:        "GET:/ping",
 			MetricType:      flow.QPS,
diff --git a/adapter/gin/middleware_test.go b/adapter/gin/middleware_test.go
index ca74df7..a459331 100644
--- a/adapter/gin/middleware_test.go
+++ b/adapter/gin/middleware_test.go
@@ -18,7 +18,7 @@ func initSentinel(t *testing.T) {
 		t.Fatalf("Unexpected error: %+v", err)
 	}
 
-	_, err = flow.LoadRules([]*flow.FlowRule{
+	_, err = flow.LoadRules([]*flow.Rule{
 		{
 			Resource:        "GET:/ping",
 			MetricType:      flow.QPS,
diff --git a/adapter/grpc/client_test.go b/adapter/grpc/client_test.go
index 319b4ed..3b4d4f4 100644
--- a/adapter/grpc/client_test.go
+++ b/adapter/grpc/client_test.go
@@ -23,7 +23,7 @@ func TestUnaryClientIntercept(t *testing.T) {
 	}
 	method := "/grpc.testing.TestService/UnaryCall"
 	t.Run("success", func(t *testing.T) {
-		var _, err = flow.LoadRules([]*flow.FlowRule{
+		var _, err = flow.LoadRules([]*flow.Rule{
 			{
 				Resource:        "client:" + method,
 				MetricType:      flow.QPS,
@@ -41,7 +41,7 @@ func TestUnaryClientIntercept(t *testing.T) {
 	})
 
 	t.Run("fail", func(t *testing.T) {
-		var _, err = flow.LoadRules([]*flow.FlowRule{
+		var _, err = flow.LoadRules([]*flow.Rule{
 			{
 				Resource:        "client:" + method,
 				MetricType:      flow.QPS,
@@ -67,7 +67,7 @@ func TestStreamClientIntercept(t *testing.T) {
 	}
 	method := "/grpc.testing.TestService/StreamingOutputCall"
 	t.Run("success", func(t *testing.T) {
-		var _, err = flow.LoadRules([]*flow.FlowRule{
+		var _, err = flow.LoadRules([]*flow.Rule{
 			{
 				Resource:        "client:/grpc.testing.TestService/StreamingOutputCall",
 				MetricType:      flow.QPS,
@@ -87,7 +87,7 @@ func TestStreamClientIntercept(t *testing.T) {
 	})
 
 	t.Run("fail", func(t *testing.T) {
-		var _, err = flow.LoadRules([]*flow.FlowRule{
+		var _, err = flow.LoadRules([]*flow.Rule{
 			{
 				Resource:        "client:/grpc.testing.TestService/StreamingOutputCall",
 				MetricType:      flow.QPS,
diff --git a/adapter/grpc/server_test.go b/adapter/grpc/server_test.go
index 68b8d89..8292921 100644
--- a/adapter/grpc/server_test.go
+++ b/adapter/grpc/server_test.go
@@ -29,7 +29,7 @@ func TestStreamServerIntercept(t *testing.T) {
 	}
 
 	t.Run("success", func(t *testing.T) {
-		var _, err = flow.LoadRules([]*flow.FlowRule{
+		var _, err = flow.LoadRules([]*flow.Rule{
 			{
 				Resource:        "/grpc.testing.TestService/StreamingInputCall",
 				MetricType:      flow.QPS,
@@ -47,7 +47,7 @@ func TestStreamServerIntercept(t *testing.T) {
 	})
 
 	t.Run("fail", func(t *testing.T) {
-		var _, err = flow.LoadRules([]*flow.FlowRule{
+		var _, err = flow.LoadRules([]*flow.Rule{
 			{
 				Resource:        "/grpc.testing.TestService/StreamingInputCall",
 				MetricType:      flow.QPS,
@@ -71,7 +71,7 @@ func TestUnaryServerIntercept(t *testing.T) {
 		FullMethod: "/grpc.testing.TestService/UnaryCall",
 	}
 	t.Run("success", func(t *testing.T) {
-		var _, err = flow.LoadRules([]*flow.FlowRule{
+		var _, err = flow.LoadRules([]*flow.Rule{
 			{
 				Resource:        "/grpc.testing.TestService/UnaryCall",
 				MetricType:      flow.QPS,
@@ -99,7 +99,7 @@ func TestUnaryServerIntercept(t *testing.T) {
 		return "abc", nil
 	}
 	t.Run("fail", func(t *testing.T) {
-		var _, err = flow.LoadRules([]*flow.FlowRule{
+		var _, err = flow.LoadRules([]*flow.Rule{
 			{
 				Resource:        "/grpc.testing.TestService/UnaryCall",
 				MetricType:      flow.QPS,
diff --git a/adapter/micro/client_test.go b/adapter/micro/client_test.go
index e49095c..14b588e 100644
--- a/adapter/micro/client_test.go
+++ b/adapter/micro/client_test.go
@@ -45,7 +45,7 @@ func TestClientLimiter(t *testing.T) {
 	rsp := &proto.Response{}
 
 	t.Run("success", func(t *testing.T) {
-		var _, err = flow.LoadRules([]*flow.FlowRule{
+		var _, err = flow.LoadRules([]*flow.Rule{
 			{
 				Resource:        req.Method(),
 				MetricType:      flow.QPS,
diff --git a/adapter/micro/server_test.go b/adapter/micro/server_test.go
index a6820f5..9a3912d 100644
--- a/adapter/micro/server_test.go
+++ b/adapter/micro/server_test.go
@@ -55,7 +55,7 @@ func TestServerLimiter(t *testing.T) {
 		log.Fatal(err)
 	}
 
-	_, err = flow.LoadRules([]*flow.FlowRule{
+	_, err = flow.LoadRules([]*flow.Rule{
 		{
 			Resource:        req.Method(),
 			MetricType:      flow.QPS,
@@ -69,7 +69,7 @@ func TestServerLimiter(t *testing.T) {
 	var rsp = &proto.Response{}
 
 	t.Run("success", func(t *testing.T) {
-		var _, err = flow.LoadRules([]*flow.FlowRule{
+		var _, err = flow.LoadRules([]*flow.Rule{
 			{
 				Resource:        req.Method(),
 				MetricType:      flow.QPS,
diff --git a/core/flow/rule_manager_test.go b/core/flow/rule_manager_test.go
index c841a15..b308e0d 100644
--- a/core/flow/rule_manager_test.go
+++ b/core/flow/rule_manager_test.go
@@ -9,7 +9,7 @@ import (
 func TestSetAndRemoveTrafficShapingGenerator(t *testing.T) {
 	tsc := NewTrafficShapingController(nil, nil, nil)
 
-	err := SetTrafficShapingGenerator(Reject, func(_ *FlowRule) *TrafficShapingController {
+	err := SetTrafficShapingGenerator(Reject, func(_ *Rule) *TrafficShapingController {
 		return tsc
 	})
 	assert.Error(t, err, "default control behaviors are not allowed to be modified")
@@ -17,13 +17,13 @@ func TestSetAndRemoveTrafficShapingGenerator(t *testing.T) {
 	assert.Error(t, err, "default control behaviors are not allowed to be removed")
 
 	cb := ControlBehavior(9999)
-	err = SetTrafficShapingGenerator(cb, func(_ *FlowRule) *TrafficShapingController {
+	err = SetTrafficShapingGenerator(cb, func(_ *Rule) *TrafficShapingController {
 		return tsc
 	})
 	assert.NoError(t, err)
 
 	resource := "test-customized-tc"
-	_, err = LoadRules([]*FlowRule{
+	_, err = LoadRules([]*Rule{
 		{
 			ID:              10,
 			Count:           20,
@@ -41,19 +41,17 @@ func TestSetAndRemoveTrafficShapingGenerator(t *testing.T) {
 	assert.NoError(t, err)
 	assert.NotContains(t, tcGenFuncMap, cb)
 
-	_, _ = LoadRules([]*FlowRule{})
+	_, _ = LoadRules([]*Rule{})
 }
 
 func TestIsValidFlowRule(t *testing.T) {
-	badRule1 := &FlowRule{ID: 1, Count: 1, MetricType: QPS, Resource: ""}
-	badRule2 := &FlowRule{ID: 1, Count: -1.9, MetricType: QPS, Resource: "test"}
-	badRule3 := &FlowRule{Count: 5, MetricType: QPS, Resource: "test", ClusterMode: true}
-	badRule4 := &FlowRule{Count: 5, MetricType: QPS, Resource: "test", ControlBehavior: WarmUp}
-	goodRule1 := &FlowRule{Count: 10, MetricType: QPS, Resource: "test", ControlBehavior: Throttling}
+	badRule1 := &Rule{ID: 1, Count: 1, MetricType: QPS, Resource: ""}
+	badRule2 := &Rule{ID: 1, Count: -1.9, MetricType: QPS, Resource: "test"}
+	badRule3 := &Rule{Count: 5, MetricType: QPS, Resource: "test", ControlBehavior: WarmUp}
+	goodRule1 := &Rule{Count: 10, MetricType: QPS, Resource: "test", ControlBehavior: Throttling}
 
 	assert.Error(t, IsValidFlowRule(badRule1))
 	assert.Error(t, IsValidFlowRule(badRule2))
 	assert.Error(t, IsValidFlowRule(badRule3))
-	assert.Error(t, IsValidFlowRule(badRule4))
 	assert.NoError(t, IsValidFlowRule(goodRule1))
 }
diff --git a/example/qps/qps_limit_example_test.go b/example/qps/qps_limit_example_test.go
index b8ae709..f821e4a 100644
--- a/example/qps/qps_limit_example_test.go
+++ b/example/qps/qps_limit_example_test.go
@@ -26,7 +26,7 @@ func doTest() {
 		log.Fatalf("Unexpected error: %+v", err)
 	}
 
-	_, err = flow.LoadRules([]*flow.FlowRule{
+	_, err = flow.LoadRules([]*flow.Rule{
 		{
 			Resource:        "some-test",
 			MetricType:      flow.QPS,
diff --git a/example/warm_up/qps_warm_up_example_test.go b/example/warm_up/qps_warm_up_example_test.go
index 1996c8c..075502b 100644
--- a/example/warm_up/qps_warm_up_example_test.go
+++ b/example/warm_up/qps_warm_up_example_test.go
@@ -28,7 +28,7 @@ func doTest() {
 		log.Fatalf("Unexpected error: %+v", err)
 	}
 
-	_, err = flow.LoadRules([]*flow.FlowRule{
+	_, err = flow.LoadRules([]*flow.Rule{
 		{
 			Resource:        "some-test",
 			MetricType:      flow.QPS,
diff --git a/ext/datasource/helper_test.go b/ext/datasource/helper_test.go
index f3411d6..15edf7c 100644
--- a/ext/datasource/helper_test.go
+++ b/ext/datasource/helper_test.go
@@ -44,9 +44,9 @@ func TestFlowRulesJsonConverter(t *testing.T) {
 	t.Run("TestFlowRulesJsonConverter_normal", func(t *testing.T) {
 		got, err := FlowRuleJsonArrayParser(normalSrc)
 		assert.True(t, got != nil && err == nil)
-		flowRules := got.([]*flow.FlowRule)
+		flowRules := got.([]*flow.Rule)
 		assert.True(t, len(flowRules) == 3)
-		r1 := &flow.FlowRule{
+		r1 := &flow.Rule{
 			Resource:          "abc",
 			LimitOrigin:       "default",
 			MetricType:        flow.Concurrency,
@@ -56,14 +56,10 @@ func TestFlowRulesJsonConverter(t *testing.T) {
 			RefResource:       "refDefault",
 			WarmUpPeriodSec:   10,
 			MaxQueueingTimeMs: 1000,
-			ClusterMode:       false,
-			ClusterConfig: flow.ClusterRuleConfig{
-				ThresholdType: flow.AvgLocalThreshold,
-			},
 		}
 		assert.True(t, reflect.DeepEqual(flowRules[0], r1))
 
-		r2 := &flow.FlowRule{
+		r2 := &flow.Rule{
 			Resource:          "abc",
 			LimitOrigin:       "default",
 			MetricType:        flow.QPS,
@@ -73,14 +69,10 @@ func TestFlowRulesJsonConverter(t *testing.T) {
 			RefResource:       "refDefault",
 			WarmUpPeriodSec:   20,
 			MaxQueueingTimeMs: 2000,
-			ClusterMode:       true,
-			ClusterConfig: flow.ClusterRuleConfig{
-				ThresholdType: flow.GlobalThreshold,
-			},
 		}
 		assert.True(t, reflect.DeepEqual(flowRules[1], r2))
 
-		r3 := &flow.FlowRule{
+		r3 := &flow.Rule{
 			Resource:          "abc",
 			LimitOrigin:       "default",
 			MetricType:        flow.QPS,
@@ -90,10 +82,6 @@ func TestFlowRulesJsonConverter(t *testing.T) {
 			RefResource:       "refDefault",
 			WarmUpPeriodSec:   30,
 			MaxQueueingTimeMs: 3000,
-			ClusterMode:       true,
-			ClusterConfig: flow.ClusterRuleConfig{
-				ThresholdType: flow.GlobalThreshold,
-			},
 		}
 		assert.True(t, reflect.DeepEqual(flowRules[2], r3))
 	})
@@ -102,7 +90,7 @@ func TestFlowRulesJsonConverter(t *testing.T) {
 func TestFlowRulesUpdater(t *testing.T) {
 	t.Run("TestFlowRulesUpdater_Nil", func(t *testing.T) {
 		flow.ClearRules()
-		flow.LoadRules([]*flow.FlowRule{
+		flow.LoadRules([]*flow.Rule{
 			{
 				ID:                0,
 				Resource:          "abc",
@@ -114,8 +102,6 @@ func TestFlowRulesUpdater(t *testing.T) {
 				RefResource:       "",
 				WarmUpPeriodSec:   0,
 				MaxQueueingTimeMs: 0,
-				ClusterMode:       false,
-				ClusterConfig:     flow.ClusterRuleConfig{},
 			}})
 		assert.True(t, len(flow.GetRules()) == 1, "Fail to prepare test data.")
 		err := FlowRulesUpdater(nil)
@@ -125,20 +111,20 @@ func TestFlowRulesUpdater(t *testing.T) {
 	t.Run("TestFlowRulesUpdater_Assert_Failed", func(t *testing.T) {
 		flow.ClearRules()
 		err := FlowRulesUpdater("xxxxxxxx")
-		assert.True(t, err != nil && strings.Contains(err.Error(), "Fail to type assert data to []flow.FlowRule"))
+		assert.True(t, err != nil && strings.Contains(err.Error(), "Fail to type assert data to []flow.Rule"))
 	})
 
 	t.Run("TestFlowRulesUpdater_Empty_Rules", func(t *testing.T) {
 		flow.ClearRules()
-		p := make([]flow.FlowRule, 0)
+		p := make([]flow.Rule, 0)
 		err := FlowRulesUpdater(p)
 		assert.True(t, err == nil && len(flow.GetRules()) == 0)
 	})
 
 	t.Run("TestFlowRulesUpdater_Normal", func(t *testing.T) {
 		flow.ClearRules()
-		p := make([]flow.FlowRule, 0)
-		fw := flow.FlowRule{
+		p := make([]flow.Rule, 0)
+		fw := flow.Rule{
 			ID:                0,
 			Resource:          "aaaa",
 			LimitOrigin:       "aaa",
@@ -149,8 +135,6 @@ func TestFlowRulesUpdater(t *testing.T) {
 			RefResource:       "",
 			WarmUpPeriodSec:   0,
 			MaxQueueingTimeMs: 0,
-			ClusterMode:       false,
-			ClusterConfig:     flow.ClusterRuleConfig{},
 		}
 		p = append(p, fw)
 		err := FlowRulesUpdater(p)
diff --git a/tests/testdata/extension/helper/FlowRule.json b/tests/testdata/extension/helper/FlowRule.json
index ee75e4c..e7ff4f0 100644
--- a/tests/testdata/extension/helper/FlowRule.json
+++ b/tests/testdata/extension/helper/FlowRule.json
@@ -8,11 +8,7 @@
         "controlBehavior": 0,
         "refResource": "refDefault",
         "warmUpPeriodSec": 10,
-        "maxQueueingTimeMs": 1000,
-        "clusterMode": false,
-        "clusterConfig": {
-            "thresholdType": 0
-        }
+        "maxQueueingTimeMs": 1000
     },
     {
         "resource": "abc",
@@ -23,11 +19,7 @@
         "controlBehavior": 1,
         "refResource": "refDefault",
         "warmUpPeriodSec": 20,
-        "maxQueueingTimeMs": 2000,
-        "clusterMode": true,
-        "clusterConfig": {
-            "thresholdType": 1
-        }
+        "maxQueueingTimeMs": 2000
     },
     {
         "resource": "abc",
@@ -38,10 +30,6 @@
         "controlBehavior": 1,
         "refResource": "refDefault",
         "warmUpPeriodSec": 30,
-        "maxQueueingTimeMs": 3000,
-        "clusterMode": true,
-        "clusterConfig": {
-            "thresholdType": 1
-        }
+        "maxQueueingTimeMs": 3000
     }
 ]
\ No newline at end of file