Skip to content

Commit

Permalink
filter: refine comments and function visibility (#2308) (#2311)
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot authored Jul 19, 2021
1 parent 03f9f2f commit e3cf5d1
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions pkg/filter/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@ import (
filterV2 "github.com/pingcap/tidb-tools/pkg/table-filter"
)

// Filter is a event filter implementation
// Filter is a event filter implementation.
type Filter struct {
filter filterV2.Filter
ignoreTxnStartTs []uint64
ddlAllowlist []model.ActionType
isCyclicEnabled bool
}

// VerifyRules ...
// VerifyRules checks the filter rules in the configuration
// and returns an invalid rule error if the verification fails, otherwise it will return the parsed filter.
func VerifyRules(cfg *config.ReplicaConfig) (filterV2.Filter, error) {
var f filterV2.Filter
var err error
Expand All @@ -50,7 +51,7 @@ func VerifyRules(cfg *config.ReplicaConfig) (filterV2.Filter, error) {
return f, nil
}

// NewFilter creates a filter
// NewFilter creates a filter.
func NewFilter(cfg *config.ReplicaConfig) (*Filter, error) {
f, err := VerifyRules(cfg)
if err != nil {
Expand Down Expand Up @@ -78,9 +79,9 @@ func (f *Filter) shouldIgnoreStartTs(ts uint64) bool {
}

// ShouldIgnoreTable returns true if the specified table should be ignored by this change feed.
// Set `tbl` to an empty string to test against the whole database.
// NOTICE: Set `tbl` to an empty string to test against the whole database.
func (f *Filter) ShouldIgnoreTable(db, tbl string) bool {
if IsSysSchema(db) {
if isSysSchema(db) {
return true
}
if f.isCyclicEnabled && mark.IsMarkTable(db, tbl) {
Expand Down Expand Up @@ -110,7 +111,7 @@ func (f *Filter) ShouldIgnoreDDLEvent(ts uint64, ddlType model.ActionType, schem
return f.shouldIgnoreStartTs(ts) || shouldIgnoreTableOrSchema
}

// ShouldDiscardDDL returns true if this DDL should be discarded
// ShouldDiscardDDL returns true if this DDL should be discarded.
func (f *Filter) ShouldDiscardDDL(ddlType model.ActionType) bool {
if !f.shouldDiscardByBuiltInDDLAllowlist(ddlType) {
return false
Expand Down Expand Up @@ -180,7 +181,7 @@ func (f *Filter) shouldDiscardByBuiltInDDLAllowlist(ddlType model.ActionType) bo
return true
}

// IsSysSchema returns true if the given schema is a system schema
func IsSysSchema(db string) bool {
// isSysSchema returns true if the given schema is a system schema
func isSysSchema(db string) bool {
return filterV1.IsSystemSchema(db)
}

0 comments on commit e3cf5d1

Please sign in to comment.