ConnectBinlogStreamer
(coordinates mysql.BinlogCoordinates)
| 56 | |
| 57 | // ConnectBinlogStreamer |
| 58 | func (gmr *GoMySQLReader) ConnectBinlogStreamer(coordinates mysql.BinlogCoordinates) (err error) { |
| 59 | if coordinates.IsEmpty() { |
| 60 | return gmr.migrationContext.Log.Errorf("empty coordinates at ConnectBinlogStreamer()") |
| 61 | } |
| 62 | |
| 63 | gmr.currentCoordinatesMutex.Lock() |
| 64 | defer gmr.currentCoordinatesMutex.Unlock() |
| 65 | gmr.currentCoordinates = coordinates |
| 66 | gmr.migrationContext.Log.Infof("Connecting binlog streamer at %+v", coordinates) |
| 67 | |
| 68 | // Start sync with specified GTID set or binlog file and position |
| 69 | if gmr.migrationContext.UseGTIDs { |
| 70 | coords := coordinates.(*mysql.GTIDBinlogCoordinates) |
| 71 | gmr.binlogStreamer, err = gmr.binlogSyncer.StartSyncGTID(coords.GTIDSet) |
| 72 | } else { |
| 73 | coords := gmr.currentCoordinates.(*mysql.FileBinlogCoordinates) |
| 74 | gmr.binlogStreamer, err = gmr.binlogSyncer.StartSync(gomysql.Position{ |
| 75 | Name: coords.LogFile, |
| 76 | Pos: uint32(coords.LogPos)}, |
| 77 | ) |
| 78 | } |
| 79 | return err |
| 80 | } |
| 81 | |
| 82 | func (gmr *GoMySQLReader) GetCurrentBinlogCoordinates() mysql.BinlogCoordinates { |
| 83 | gmr.currentCoordinatesMutex.Lock() |
no test coverage detected