Skip to content

Commit c3e7644

Browse files
committed
feat: added ConnectionMaxIdleTime to SQL Config struct
1 parent b973d76 commit c3e7644

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

sql/connection.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff 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
1819
func 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

0 commit comments

Comments
 (0)