File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -11,18 +11,21 @@ type (
1111 MaxOpenConnections int
1212 MaxIdleConnections int
1313 ConnectionMaxLifetime time.Duration
14+ ConnectionMaxIdleTime time.Duration
1415 }
1516)
1617
1718// NewConfig creates a new configuration
1819func NewConfig (
19- maxOpenConnections int ,
20+ maxOpenConnections ,
2021 maxIdleConnections int ,
22+ connectionMaxIdleTime ,
2123 connectionMaxLifetime time.Duration ,
2224) * Config {
2325 return & Config {
2426 MaxOpenConnections : maxOpenConnections ,
2527 MaxIdleConnections : maxIdleConnections ,
28+ ConnectionMaxIdleTime : connectionMaxIdleTime ,
2629 ConnectionMaxLifetime : connectionMaxLifetime ,
2730 }
2831}
@@ -52,6 +55,9 @@ func Connect(
5255 // Set the connection max lifetime
5356 db .SetConnMaxLifetime (config .ConnectionMaxLifetime )
5457
58+ // Set the connection max idle time
59+ db .SetConnMaxIdleTime (config .ConnectionMaxIdleTime )
60+
5561 return db , nil
5662}
5763
You can’t perform that action at this time.
0 commit comments