Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions canal/canal.go
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,12 @@ func (c *Canal) prepareSyncer() error {
Dialer: c.cfg.Dialer,
Localhost: c.cfg.Localhost,
EventCacheCount: c.cfg.EventCacheCount,
RowsEventDecodeFunc: func(event *replication.RowsEvent, data []byte) error {
}

if c.cfg.RowsEventDecodeFunc != nil {
cfg.RowsEventDecodeFunc = c.cfg.RowsEventDecodeFunc
} else {
cfg.RowsEventDecodeFunc = func(event *replication.RowsEvent, data []byte) error {
pos, err := event.DecodeHeader(data)
if err != nil {
return err
Expand All @@ -475,7 +480,7 @@ func (c *Canal) prepareSyncer() error {
}

return event.DecodeData(pos, data)
},
}
}

if strings.Contains(c.cfg.Addr, "/") {
Expand Down
4 changes: 4 additions & 0 deletions canal/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

"github.com/go-mysql-org/go-mysql/client"
"github.com/go-mysql-org/go-mysql/mysql"
"github.com/go-mysql-org/go-mysql/replication"
)

type DumpConfig struct {
Expand Down Expand Up @@ -71,6 +72,9 @@ type Config struct {
IncludeTableRegex []string `toml:"include_table_regex"`
ExcludeTableRegex []string `toml:"exclude_table_regex"`

// Allows to specify a custom function to decode RowsEvent. This can be used to skip decoding of some events.
RowsEventDecodeFunc func(*replication.RowsEvent, []byte) error

// discard row event without table meta
DiscardNoMetaRowEvent bool `toml:"discard_no_meta_row_event"`

Expand Down