(dbVersion string, connectionConfig *ConnectionConfig, visitedKeys *InstanceKeyMap, allowMasterMaster bool)
| 130 | } |
| 131 | |
| 132 | func GetMasterConnectionConfigSafe(dbVersion string, connectionConfig *ConnectionConfig, visitedKeys *InstanceKeyMap, allowMasterMaster bool) (masterConfig *ConnectionConfig, err error) { |
| 133 | log.Debugf("Looking for %s on %+v", ReplicaTermFor(dbVersion, "master"), connectionConfig.Key) |
| 134 | |
| 135 | masterKey, err := GetMasterKeyFromSlaveStatus(dbVersion, connectionConfig) |
| 136 | if err != nil { |
| 137 | return nil, err |
| 138 | } |
| 139 | if masterKey == nil { |
| 140 | return connectionConfig, nil |
| 141 | } |
| 142 | if !masterKey.IsValid() { |
| 143 | return connectionConfig, nil |
| 144 | } |
| 145 | |
| 146 | masterConfig = connectionConfig.DuplicateCredentials(*masterKey) |
| 147 | if err := masterConfig.RegisterTLSConfig(); err != nil { |
| 148 | return nil, err |
| 149 | } |
| 150 | |
| 151 | log.Debugf("%s of %+v is %+v", ReplicaTermFor(dbVersion, "master"), connectionConfig.Key, masterConfig.Key) |
| 152 | if visitedKeys.HasKey(masterConfig.Key) { |
| 153 | if allowMasterMaster { |
| 154 | return connectionConfig, nil |
| 155 | } |
| 156 | return nil, fmt.Errorf("there seems to be a master-master setup at %+v. This is unsupported. Bailing out", masterConfig.Key) |
| 157 | } |
| 158 | visitedKeys.AddKey(masterConfig.Key) |
| 159 | return GetMasterConnectionConfigSafe(dbVersion, masterConfig, visitedKeys, allowMasterMaster) |
| 160 | } |
| 161 | |
| 162 | func GetReplicationBinlogCoordinates(dbVersion string, db *gosql.DB, gtid bool) (readBinlogCoordinates, executeBinlogCoordinates BinlogCoordinates, err error) { |
| 163 | showReplicaStatusQuery := fmt.Sprintf("show %s", ReplicaTermFor(dbVersion, `slave status`)) |
no test coverage detected
searching dependent graphs…