1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-25 23:01:28 +00:00

修复数据库连接异常问题

This commit is contained in:
leapsea 2020-05-09 16:31:30 +08:00
parent 8f3d1c5f42
commit 867f83de34

View File

@ -374,6 +374,7 @@ func SetMaxIdleConns(aliasName string, maxIdleConns int) {
func SetMaxOpenConns(aliasName string, maxOpenConns int) { func SetMaxOpenConns(aliasName string, maxOpenConns int) {
al := getDbAlias(aliasName) al := getDbAlias(aliasName)
al.MaxOpenConns = maxOpenConns al.MaxOpenConns = maxOpenConns
al.DB.DB.SetMaxOpenConns(maxOpenConns)
// for tip go 1.2 // for tip go 1.2
if fun := reflect.ValueOf(al.DB).MethodByName("SetMaxOpenConns"); fun.IsValid() { if fun := reflect.ValueOf(al.DB).MethodByName("SetMaxOpenConns"); fun.IsValid() {
fun.Call([]reflect.Value{reflect.ValueOf(maxOpenConns)}) fun.Call([]reflect.Value{reflect.ValueOf(maxOpenConns)})