chore: stabilize lint and verify builds
This commit is contained in:
@@ -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 校验
|
||||
|
||||
Reference in New Issue
Block a user