mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-06-06 22:49:35 +08:00
feat(connection): 添加MySQL超时配置
This commit is contained in:
@@ -30,8 +30,13 @@ func (m *MySQLDB) getDSN(config connection.ConnectionConfig) string {
|
||||
}
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%s:%s@%s(%s)/%s?charset=utf8mb4&parseTime=True&loc=Local",
|
||||
config.User, config.Password, protocol, address, database)
|
||||
timeout := config.Timeout
|
||||
if timeout <= 0 {
|
||||
timeout = 30
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%s:%s@%s(%s)/%s?charset=utf8mb4&parseTime=True&loc=Local&timeout=%ds",
|
||||
config.User, config.Password, protocol, address, database, timeout)
|
||||
}
|
||||
|
||||
func (m *MySQLDB) Connect(config connection.ConnectionConfig) error {
|
||||
|
||||
Reference in New Issue
Block a user