Skip to content

Commit b399533

Browse files
author
Nikhil Mathew
committed
Simplify GoMySQLReader
1 parent 982b8ee commit b399533

2 files changed

Lines changed: 8 additions & 10 deletions

File tree

go/binlog/gomysql_reader.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,26 @@ type GoMySQLReader struct {
2626
currentCoordinates mysql.BinlogCoordinates
2727
currentCoordinatesMutex *sync.Mutex
2828
LastAppliedRowsEventHint mysql.BinlogCoordinates
29-
MigrationContext *base.MigrationContext
3029
}
3130

32-
func NewGoMySQLReader(migrationContext *base.MigrationContext, connectionConfig *mysql.ConnectionConfig) (binlogReader *GoMySQLReader, err error) {
31+
func NewGoMySQLReader(migrationContext *base.MigrationContext) (binlogReader *GoMySQLReader, err error) {
3332
binlogReader = &GoMySQLReader{
34-
connectionConfig: connectionConfig,
33+
connectionConfig: migrationContext.InspectorConnectionConfig,
3534
currentCoordinates: mysql.BinlogCoordinates{},
3635
currentCoordinatesMutex: &sync.Mutex{},
3736
binlogSyncer: nil,
3837
binlogStreamer: nil,
39-
MigrationContext: migrationContext,
4038
}
4139

42-
serverId := uint32(binlogReader.MigrationContext.ReplicaServerId)
40+
serverId := uint32(migrationContext.ReplicaServerId)
4341

4442
binlogSyncerConfig := &replication.BinlogSyncerConfig{
4543
ServerID: serverId,
4644
Flavor: "mysql",
47-
Host: connectionConfig.Key.Hostname,
48-
Port: uint16(connectionConfig.Key.Port),
49-
User: connectionConfig.User,
50-
Password: connectionConfig.Password,
45+
Host: binlogReader.connectionConfig.Key.Hostname,
46+
Port: uint16(binlogReader.connectionConfig.Key.Port),
47+
User: binlogReader.connectionConfig.User,
48+
Password: binlogReader.connectionConfig.Password,
5149
}
5250
binlogReader.binlogSyncer = replication.NewBinlogSyncer(binlogSyncerConfig)
5351

go/logic/streamer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func (this *EventsStreamer) InitDBConnections() (err error) {
122122

123123
// initBinlogReader creates and connects the reader: we hook up to a MySQL server as a replica
124124
func (this *EventsStreamer) initBinlogReader(binlogCoordinates *mysql.BinlogCoordinates) error {
125-
goMySQLReader, err := binlog.NewGoMySQLReader(this.migrationContext, this.migrationContext.InspectorConnectionConfig)
125+
goMySQLReader, err := binlog.NewGoMySQLReader(this.migrationContext)
126126
if err != nil {
127127
return err
128128
}

0 commit comments

Comments
 (0)