Files
MyGoNavi/internal/db/timeout.go
杨国锋 99c21f4fd4 🐛 fix(connection): 修复多数据源连接测试成功但实际失败,closes #23
- 前端改用通用 DB API,避免强制走 MySQL 接口导致 PostgreSQL 等连接异常
  - 后端统一各数据源 timeout(Ping 超时 + 连接参数注入)
  - DSN 生成兼容特殊字符密码(Postgres/Oracle/达梦/金仓)
  - 增加文件日志与错误链输出,连接失败提示日志路径便于排障
2026-02-03 12:23:37 +08:00

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
}