From cbfc6ea69cd833ddfd79435bec2d0302a8d44827 Mon Sep 17 00:00:00 2001 From: fengwei Date: Fri, 17 Jul 2020 10:44:05 +0800 Subject: [PATCH 1/2] Add function to extend replication parameters --- replication/binlogsyncer.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/replication/binlogsyncer.go b/replication/binlogsyncer.go index 2cec5de87..398190924 100644 --- a/replication/binlogsyncer.go +++ b/replication/binlogsyncer.go @@ -104,6 +104,8 @@ type BinlogSyncerConfig struct { // https://mariadb.com/kb/en/library/com_binlog_dump/ // https://mariadb.com/kb/en/library/annotate_rows_event/ DumpCommandFlag uint16 + + Option func(*client.Conn) error } // BinlogSyncer syncs binlog event from server. @@ -223,6 +225,12 @@ func (b *BinlogSyncer) registerSlave() error { return errors.Trace(err) } + if b.cfg.Option != nil { + if err = b.cfg.Option(b.c); err != nil { + return errors.Trace(err) + } + } + if len(b.cfg.Charset) != 0 { b.c.SetCharset(b.cfg.Charset) } From c23dfad803bc3052049c60a1a7a9d7e7b46055e5 Mon Sep 17 00:00:00 2001 From: fengwei Date: Mon, 20 Jul 2020 19:36:27 +0800 Subject: [PATCH 2/2] add comment --- replication/binlogsyncer.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/replication/binlogsyncer.go b/replication/binlogsyncer.go index 398190924..c974cd249 100644 --- a/replication/binlogsyncer.go +++ b/replication/binlogsyncer.go @@ -105,6 +105,8 @@ type BinlogSyncerConfig struct { // https://mariadb.com/kb/en/library/annotate_rows_event/ DumpCommandFlag uint16 + //Option function is used to set outside of BinlogSyncerConfig, between mysql connection and COM_REGISTER_SLAVE + //For MariaDB: slave_gtid_ignore_duplicates、skip_replication、slave_until_gtid Option func(*client.Conn) error }