Skip to content

Commit

Permalink
*: replace ddl-white-list with ddl-allow-list (#698)
Browse files Browse the repository at this point in the history
  • Loading branch information
amyangfei authored Jun 28, 2020
1 parent bd3dd71 commit 5cd12d3
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions cdc/model/changefeed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (s *configSuite) TestFillV1(c *check.C) {
1,
2
],
"ddl-white-list":"AQI="
"ddl-allow-list":"AQI="
},
"mounter":{
"worker-num":64
Expand Down Expand Up @@ -134,7 +134,7 @@ func (s *configSuite) TestFillV1(c *check.C) {
IgnoreDBs: []string{"test", "sys"},
},
IgnoreTxnStartTs: []uint64{1, 2},
DDLWhitelist: []model.ActionType{1, 2},
DDLAllowlist: []model.ActionType{1, 2},
},
Mounter: &config.MounterConfig{
WorkerNum: 64,
Expand Down
4 changes: 2 additions & 2 deletions cmd/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ case-sensitive = false
[filter]
ignore-txn-start-ts = [1, 2]
ddl-white-list = [1, 2]
ddl-allow-list = [1, 2]
rules = ['*.*', '!test.*']
[mounter]
Expand Down Expand Up @@ -72,7 +72,7 @@ polling-time = 5
c.Assert(cfg.CaseSensitive, check.IsFalse)
c.Assert(cfg.Filter, check.DeepEquals, &config.FilterConfig{
IgnoreTxnStartTs: []uint64{1, 2},
DDLWhitelist: []model.ActionType{1, 2},
DDLAllowlist: []model.ActionType{1, 2},
Rules: []string{"*.*", "!test.*"},
})
c.Assert(cfg.Mounter, check.DeepEquals, &config.MounterConfig{
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ type FilterConfig struct {
Rules []string `toml:"rules" json:"rules"`
*filter.MySQLReplicationRules
IgnoreTxnStartTs []uint64 `toml:"ignore-txn-start-ts" json:"ignore-txn-start-ts"`
DDLWhitelist []model.ActionType `toml:"ddl-white-list" json:"ddl-white-list"`
DDLAllowlist []model.ActionType `toml:"ddl-allow-list" json:"ddl-allow-list"`
}
12 changes: 6 additions & 6 deletions pkg/filter/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
type Filter struct {
filter filter.Filter
ignoreTxnStartTs []uint64
ddlWhitelist []model.ActionType
ddlAllowlist []model.ActionType
isCyclicEnabled bool
}

Expand All @@ -53,7 +53,7 @@ func NewFilter(cfg *config.ReplicaConfig) (*Filter, error) {
return &Filter{
filter: f,
ignoreTxnStartTs: cfg.Filter.IgnoreTxnStartTs,
ddlWhitelist: cfg.Filter.DDLWhitelist,
ddlAllowlist: cfg.Filter.DDLAllowlist,
isCyclicEnabled: cfg.Cyclic.IsEnabled(),
}, nil
}
Expand Down Expand Up @@ -94,18 +94,18 @@ func (f *Filter) ShouldIgnoreDDLEvent(ts uint64, schema, table string) bool {

// ShouldDiscardDDL returns true if this DDL should be discarded
func (f *Filter) ShouldDiscardDDL(ddlType model.ActionType) bool {
if !f.shouldDiscardByBuiltInDDLWhitelist(ddlType) {
if !f.shouldDiscardByBuiltInDDLAllowlist(ddlType) {
return false
}
for _, whiteDDLType := range f.ddlWhitelist {
if whiteDDLType == ddlType {
for _, allowDDLType := range f.ddlAllowlist {
if allowDDLType == ddlType {
return false
}
}
return true
}

func (f *Filter) shouldDiscardByBuiltInDDLWhitelist(ddlType model.ActionType) bool {
func (f *Filter) shouldDiscardByBuiltInDDLAllowlist(ddlType model.ActionType) bool {
/* The following DDL will be filter:
ActionAddForeignKey ActionType = 9
ActionDropForeignKey ActionType = 10
Expand Down
2 changes: 1 addition & 1 deletion pkg/filter/filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (s *filterSuite) TestShouldIgnoreTxn(c *check.C) {
func (s *filterSuite) TestShouldDiscardDDL(c *check.C) {
config := &config.ReplicaConfig{
Filter: &config.FilterConfig{
DDLWhitelist: []model.ActionType{model.ActionAddForeignKey},
DDLAllowlist: []model.ActionType{model.ActionAddForeignKey},
},
}
filter, err := NewFilter(config)
Expand Down

0 comments on commit 5cd12d3

Please sign in to comment.