完善数据库 SQL 约束与运维治理

This commit is contained in:
yml2213
2026-08-31 12:58:28 +08:00
parent 1ee7d17712
commit ad279049a0
12 changed files with 283 additions and 8 deletions
+7 -1
View File
@@ -58,7 +58,13 @@ func main() {
logAuthRuntimeIdentity(logger, cfg)
var deps router.Dependencies
db, err := database.OpenMySQL(cfg.MySQLDSN, cfg.Log.Level, logger)
db, err := database.OpenMySQLWithOptions(cfg.MySQLDSN, cfg.Log.Level, logger, database.MySQLOptions{
MaxOpenConns: cfg.Database.MaxOpenConns,
MaxIdleConns: cfg.Database.MaxIdleConns,
ConnMaxLifetime: cfg.Database.ConnMaxLifetime,
ConnMaxIdleTime: cfg.Database.ConnMaxIdleTime,
SlowQueryThreshold: cfg.Database.SlowQueryThreshold,
})
if err != nil {
logger.Warn("MySQL 不可用,数据库接口将返回 503", zap.Error(err))
} else {