orm RegisterDataBase remove default maxIdle/maxConn
Showing
1 changed file
with
8 additions
and
17 deletions
| ... | @@ -9,9 +9,6 @@ import ( | ... | @@ -9,9 +9,6 @@ import ( |
| 9 | "time" | 9 | "time" |
| 10 | ) | 10 | ) |
| 11 | 11 | ||
| 12 | const defaultMaxIdleConns = 30 | ||
| 13 | const defaultMaxOpenConns = 50 | ||
| 14 | |||
| 15 | type DriverType int | 12 | type DriverType int |
| 16 | 13 | ||
| 17 | const ( | 14 | const ( |
| ... | @@ -92,18 +89,6 @@ type alias struct { | ... | @@ -92,18 +89,6 @@ type alias struct { |
| 92 | 89 | ||
| 93 | // Setting the database connect params. Use the database driver self dataSource args. | 90 | // Setting the database connect params. Use the database driver self dataSource args. |
| 94 | func RegisterDataBase(aliasName, driverName, dataSource string, params ...int) { | 91 | func RegisterDataBase(aliasName, driverName, dataSource string, params ...int) { |
| 95 | maxIdleConns := defaultMaxIdleConns | ||
| 96 | maxOpenConns := defaultMaxOpenConns | ||
| 97 | |||
| 98 | for i, v := range params { | ||
| 99 | switch i { | ||
| 100 | case 0: | ||
| 101 | maxIdleConns = v | ||
| 102 | case 1: | ||
| 103 | maxOpenConns = v | ||
| 104 | } | ||
| 105 | } | ||
| 106 | |||
| 107 | al := new(alias) | 92 | al := new(alias) |
| 108 | al.Name = aliasName | 93 | al.Name = aliasName |
| 109 | al.DriverName = driverName | 94 | 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) { |
| 173 | } | 158 | } |
| 174 | } | 159 | } |
| 175 | 160 | ||
| 176 | SetMaxIdleConns(al.Name, maxIdleConns) | 161 | for i, v := range params { |
| 177 | SetMaxOpenConns(al.Name, maxOpenConns) | 162 | switch i { |
| 163 | case 0: | ||
| 164 | SetMaxIdleConns(al.Name, v) | ||
| 165 | case 1: | ||
| 166 | SetMaxOpenConns(al.Name, v) | ||
| 167 | } | ||
| 168 | } | ||
| 178 | 169 | ||
| 179 | err = al.DB.Ping() | 170 | err = al.DB.Ping() |
| 180 | if err != nil { | 171 | if err != nil { | ... | ... |
-
Please register or sign in to post a comment