完善数据库 SQL 约束与运维治理
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user