fix(db): fix SetMaxOpenConns (#328)

This commit is contained in:
HAOYUatHZ
2023-02-28 15:15:15 +08:00
committed by GitHub
parent cc64c29f56
commit 2881dbd273
6 changed files with 13 additions and 7 deletions

View File

@@ -82,6 +82,8 @@
},
"db_config": {
"driver_name": "postgres",
"dsn": "postgres://admin:123456@localhost/test?sslmode=disable"
"dsn": "postgres://admin:123456@localhost/test?sslmode=disable",
"maxOpenNum": 200,
"maxIdleNum": 20
}
}

View File

@@ -5,7 +5,7 @@ import (
"runtime/debug"
)
var tag = "alpha-v1.10"
var tag = "alpha-v1.11"
var commit = func() string {
if info, ok := debug.ReadBuildInfo(); ok {

View File

@@ -12,7 +12,9 @@
},
"db_config": {
"driver_name": "postgres",
"dsn": "postgres://admin:123456@localhost/test?sslmode=disable"
"dsn": "postgres://admin:123456@localhost/test?sslmode=disable",
"maxOpenNum": 200,
"maxIdleNum": 20
},
"l2_config": {
"endpoint": "/var/lib/jenkins/workspace/SequencerPipeline/MyPrivateNetwork/geth.ipc"

View File

@@ -12,8 +12,8 @@ type DBConfig struct {
DSN string `json:"dsn"`
DriverName string `json:"driver_name"`
MaxOpenNum int `json:"maxOpenNum" default:"200"`
MaxIdleNum int `json:"maxIdleNum" default:"20"`
MaxOpenNum int `json:"maxOpenNum"`
MaxIdleNum int `json:"maxIdleNum"`
}
// NewConfig returns a new instance of Config.

View File

@@ -1,4 +1,6 @@
{
"dsn": "postgres://postgres:123456@localhost:5444/test?sslmode=disable",
"driver_name": "postgres"
"driver_name": "postgres",
"maxOpenNum": 200,
"maxIdleNum": 20
}

View File

@@ -38,7 +38,7 @@ func NewOrmFactory(cfg *DBConfig) (OrmFactory, error) {
return nil, err
}
db.SetMaxIdleConns(cfg.MaxOpenNum)
db.SetMaxOpenConns(cfg.MaxOpenNum)
db.SetMaxIdleConns(cfg.MaxIdleNum)
if err = db.Ping(); err != nil {
return nil, err