Commit 09aca252 authored by slene's avatar slene

orm RegisterDataBase remove default maxIdle/maxConn

parent beecc507
...@@ -9,9 +9,6 @@ import ( ...@@ -9,9 +9,6 @@ import (
"time" "time"
) )
const defaultMaxIdleConns = 30
const defaultMaxOpenConns = 50
type DriverType int type DriverType int
const ( const (
...@@ -92,18 +89,6 @@ type alias struct { ...@@ -92,18 +89,6 @@ type alias struct {
// Setting the database connect params. Use the database driver self dataSource args. // Setting the database connect params. Use the database driver self dataSource args.
func RegisterDataBase(aliasName, driverName, dataSource string, params ...int) { func RegisterDataBase(aliasName, driverName, dataSource string, params ...int) {
maxIdleConns := defaultMaxIdleConns
maxOpenConns := defaultMaxOpenConns
for i, v := range params {
switch i {
case 0:
maxIdleConns = v
case 1:
maxOpenConns = v
}
}
al := new(alias) al := new(alias)
al.Name = aliasName al.Name = aliasName
al.DriverName = driverName al.DriverName = driverName
...@@ -173,8 +158,14 @@ func RegisterDataBase(aliasName, driverName, dataSource string, params ...int) { ...@@ -173,8 +158,14 @@ func RegisterDataBase(aliasName, driverName, dataSource string, params ...int) {
} }
} }
SetMaxIdleConns(al.Name, maxIdleConns) for i, v := range params {
SetMaxOpenConns(al.Name, maxOpenConns) switch i {
case 0:
SetMaxIdleConns(al.Name, v)
case 1:
SetMaxOpenConns(al.Name, v)
}
}
err = al.DB.Ping() err = al.DB.Ping()
if err != nil { if err != nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment