chore: stabilize lint and verify builds

This commit is contained in:
2026-02-06 11:51:32 +08:00
parent edede17880
commit 1782f64417
114 changed files with 3032 additions and 1345 deletions

View File

@@ -3,9 +3,10 @@ package postgres
import (
"context"
"database/sql"
"math"
"time"
"github.com/sirupsen/logrus"
logrus "github.com/sirupsen/logrus"
"go.ipao.vip/atom/container"
"go.ipao.vip/atom/opt"
"gorm.io/driver/postgres"
@@ -70,10 +71,18 @@ func Provide(opts ...opt.Option) error {
sqlDB.SetMaxIdleConns(conf.MaxIdleConns)
sqlDB.SetMaxOpenConns(conf.MaxOpenConns)
if conf.ConnMaxLifetimeSeconds > 0 {
sqlDB.SetConnMaxLifetime(time.Duration(conf.ConnMaxLifetimeSeconds) * time.Second)
if conf.ConnMaxLifetimeSeconds > math.MaxInt64/uint(time.Second) {
sqlDB.SetConnMaxLifetime(time.Duration(math.MaxInt64))
} else {
sqlDB.SetConnMaxLifetime(time.Duration(conf.ConnMaxLifetimeSeconds) * time.Second)
}
}
if conf.ConnMaxIdleTimeSeconds > 0 {
sqlDB.SetConnMaxIdleTime(time.Duration(conf.ConnMaxIdleTimeSeconds) * time.Second)
if conf.ConnMaxIdleTimeSeconds > math.MaxInt64/uint(time.Second) {
sqlDB.SetConnMaxIdleTime(time.Duration(math.MaxInt64))
} else {
sqlDB.SetConnMaxIdleTime(time.Duration(conf.ConnMaxIdleTimeSeconds) * time.Second)
}
}
// Ping 校验