Skip to content

Commit 88e9cd7

Browse files
luk3thomassiddontang
authored andcommitted
Add MaxReconnectAttempts to canal config (go-mysql-org#360)
1 parent 759c507 commit 88e9cd7

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

canal/canal.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -400,16 +400,17 @@ func (c *Canal) checkBinlogRowFormat() error {
400400

401401
func (c *Canal) prepareSyncer() error {
402402
cfg := replication.BinlogSyncerConfig{
403-
ServerID: c.cfg.ServerID,
404-
Flavor: c.cfg.Flavor,
405-
User: c.cfg.User,
406-
Password: c.cfg.Password,
407-
Charset: c.cfg.Charset,
408-
HeartbeatPeriod: c.cfg.HeartbeatPeriod,
409-
ReadTimeout: c.cfg.ReadTimeout,
410-
UseDecimal: c.cfg.UseDecimal,
411-
ParseTime: c.cfg.ParseTime,
412-
SemiSyncEnabled: c.cfg.SemiSyncEnabled,
403+
ServerID: c.cfg.ServerID,
404+
Flavor: c.cfg.Flavor,
405+
User: c.cfg.User,
406+
Password: c.cfg.Password,
407+
Charset: c.cfg.Charset,
408+
HeartbeatPeriod: c.cfg.HeartbeatPeriod,
409+
ReadTimeout: c.cfg.ReadTimeout,
410+
UseDecimal: c.cfg.UseDecimal,
411+
ParseTime: c.cfg.ParseTime,
412+
SemiSyncEnabled: c.cfg.SemiSyncEnabled,
413+
MaxReconnectAttempts: c.cfg.MaxReconnectAttempts,
413414
}
414415

415416
if strings.Contains(c.cfg.Addr, "/") {

canal/config.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ type Config struct {
7070

7171
// SemiSyncEnabled enables semi-sync or not.
7272
SemiSyncEnabled bool `toml:"semi_sync_enabled"`
73+
74+
// Set to change the maximum number of attempts to re-establish a broken
75+
// connection
76+
MaxReconnectAttempts int `toml:"max_reconnect_attempts"`
7377
}
7478

7579
func NewConfigWithFile(name string) (*Config, error) {

0 commit comments

Comments
 (0)