Refactor usages of GetDB to use mysql
This commit is contained in:
parent
bb4a0be4c6
commit
2ad65ee1d7
@ -14,12 +14,9 @@ import (
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
gosql "database/sql"
|
||||
"github.com/github/gh-ost/go/mysql"
|
||||
"github.com/github/gh-ost/go/sql"
|
||||
|
||||
"github.com/outbrain/golib/sqlutils"
|
||||
|
||||
"gopkg.in/gcfg.v1"
|
||||
gcfgscanner "gopkg.in/gcfg.v1/scanner"
|
||||
)
|
||||
|
@ -47,11 +47,11 @@ func NewApplier(migrationContext *base.MigrationContext) *Applier {
|
||||
|
||||
func (this *Applier) InitDBConnections() (err error) {
|
||||
applierUri := this.connectionConfig.GetDBUri(this.migrationContext.DatabaseName)
|
||||
if this.db, _, err = this.migrationContext.GetDB(applierUri); err != nil {
|
||||
if this.db, err = mysql.GetDB(applierUri); err != nil {
|
||||
return err
|
||||
}
|
||||
singletonApplierUri := fmt.Sprintf("%s?timeout=0", applierUri)
|
||||
if this.singletonDB, _, err = this.migrationContext.GetDB(singletonApplierUri); err != nil {
|
||||
if this.singletonDB, err = mysql.GetDB(singletonApplierUri); err != nil {
|
||||
return err
|
||||
}
|
||||
this.singletonDB.SetMaxOpenConns(1)
|
||||
|
@ -41,12 +41,12 @@ func NewInspector(migrationContext *base.MigrationContext) *Inspector {
|
||||
|
||||
func (this *Inspector) InitDBConnections() (err error) {
|
||||
inspectorUri := this.connectionConfig.GetDBUri(this.migrationContext.DatabaseName)
|
||||
if this.db, _, err = this.migrationContext.GetDB(inspectorUri); err != nil {
|
||||
if this.db, err = mysql.GetDB(inspectorUri); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
informationSchemaUri := this.connectionConfig.GetDBUri("information_schema")
|
||||
if this.informationSchemaDb, _, err = this.migrationContext.GetDB(informationSchemaUri); err != nil {
|
||||
if this.informationSchemaDb, err = mysql.GetDB(informationSchemaUri); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ func (this *EventsStreamer) notifyListeners(binlogEvent *binlog.BinlogDMLEvent)
|
||||
|
||||
func (this *EventsStreamer) InitDBConnections() (err error) {
|
||||
EventsStreamerUri := this.connectionConfig.GetDBUri(this.migrationContext.DatabaseName)
|
||||
if this.db, _, err = this.migrationContext.GetDB(EventsStreamerUri); err != nil {
|
||||
if this.db, err = mysql.GetDB(EventsStreamerUri); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := this.validateConnection(); err != nil {
|
||||
|
@ -181,7 +181,7 @@ func (this *Throttler) collectControlReplicasLag() {
|
||||
dbUri := connectionConfig.GetDBUri("information_schema")
|
||||
|
||||
var heartbeatValue string
|
||||
if db, _, err := this.migrationContext.GetDB(dbUri); err != nil {
|
||||
if db, err := mysql.GetDB(dbUri); err != nil {
|
||||
return lag, err
|
||||
} else if err = db.QueryRow(replicationLagQuery).Scan(&heartbeatValue); err != nil {
|
||||
return lag, err
|
||||
|
@ -62,7 +62,7 @@ func GetReplicationLag(informationSchemaDb *gosql.DB, connectionConfig *Connecti
|
||||
func GetMasterKeyFromSlaveStatus(connectionConfig *ConnectionConfig) (masterKey *InstanceKey, err error) {
|
||||
currentUri := connectionConfig.GetDBUri("information_schema")
|
||||
// This function is only called once, okay to not have a cached connection pool
|
||||
db, err := sqlutils.GetDB(currentUri)
|
||||
db, err := GetDB(currentUri)
|
||||
defer db.Close()
|
||||
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user