mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-05-06 20:03:05 +08:00
- 前端改用通用 DB API,避免强制走 MySQL 接口导致 PostgreSQL 等连接异常 - 后端统一各数据源 timeout(Ping 超时 + 连接参数注入) - DSN 生成兼容特殊字符密码(Postgres/Oracle/达梦/金仓) - 增加文件日志与错误链输出,连接失败提示日志路径便于排障
23 lines
467 B
Go
23 lines
467 B
Go
package db
|
|
|
|
import (
|
|
"time"
|
|
|
|
"GoNavi-Wails/internal/connection"
|
|
)
|
|
|
|
const defaultConnectTimeoutSeconds = 30
|
|
|
|
func getConnectTimeoutSeconds(config connection.ConnectionConfig) int {
|
|
timeoutSeconds := config.Timeout
|
|
if timeoutSeconds <= 0 {
|
|
timeoutSeconds = defaultConnectTimeoutSeconds
|
|
}
|
|
return timeoutSeconds
|
|
}
|
|
|
|
func getConnectTimeout(config connection.ConnectionConfig) time.Duration {
|
|
return time.Duration(getConnectTimeoutSeconds(config)) * time.Second
|
|
}
|
|
|