Skip to content

Commit

Permalink
fix: exclude all databases except cdc-observer
Browse files Browse the repository at this point in the history
  • Loading branch information
bigboss2063 committed Oct 11, 2024
1 parent b93e4c3 commit 15b3a8f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions cdcobserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ func (ob *CDCObserver) Start(ctx context.Context) error {
cfg.Addr = fmt.Sprintf("%s:%s", constant.DatabaseHost, port)
cfg.User = constant.DatabaseUsername
cfg.Password = constant.DatabasePassword
// Exclude mysql system tables
cfg.ExcludeTableRegex = []string{"mysql\\..*"}
// Disable dump by setting Dump.ExecutionPath to empty string
cfg.Dump.ExecutionPath = ""
// Exclude all databases except cdc-observer
cfg.ExcludeTableRegex = []string{"[^cdc-observer]\\..*"}
cfg.IncludeTableRegex = []string{"cdc-observer\\..*"}

c, err := canal.NewCanal(cfg)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion handler/cdcobserver_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type CDCObserverHandler struct {

// todo build a tool for print the CDC event in terminal in table style
func (h *CDCObserverHandler) OnRow(e *canal.RowsEvent) error {
log.Infof("%s %v\n", e.Action, e.Rows)
log.Infof("%s %s %v\n", e.Table, e.Action, e.Rows)
return nil
}

Expand Down

0 comments on commit 15b3a8f

Please sign in to comment.