From bb23408566e513e122f18df81c71491d49b3e106 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E6=89=8B=E6=8E=89=E5=8C=85=E5=B7=A5=E7=A8=8B?= =?UTF-8?q?=E5=B8=88?= Date: Sat, 17 Jul 2021 12:03:34 +0800 Subject: [PATCH] filter: refine comments and function visibility (#2308) --- pkg/filter/filter.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/pkg/filter/filter.go b/pkg/filter/filter.go index 15cbc933f9b..b5b7f5843d4 100644 --- a/pkg/filter/filter.go +++ b/pkg/filter/filter.go @@ -22,7 +22,7 @@ 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 @@ -30,7 +30,8 @@ type Filter struct { 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 @@ -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 { @@ -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) { @@ -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 @@ -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) }