Exemple #1
0
func makeConnection(db *mysql.DB) error {
	if db == nil {
		return fmt.Errorf("Can not make connection to database because of db is nil")
	}

	err := db.Ping()
	//TODO: retry
	if err != nil {
		log.Errorf("makeConnection error msg:%s", err.Error())
	}
	return err
}
Exemple #2
0
func setDBProperty(db *mysql.DB, nodeCfg *config.NodeConfig) {
	db.SetMaxOpenConns(nodeCfg.MaxConnections)
	db.SetMaxIdleConns(nodeCfg.MaxConnectionPoolSize)
	db.SetDbAliveStatus(true)
}