Skip to content

Commit

Permalink
Merge pull request #5 from busgo/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
busgo authored Jan 11, 2022
2 parents 5f1b0a9 + 06ed0c8 commit eb8b82e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
2 changes: 2 additions & 0 deletions app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ etcd:

mysql:
dsn: root:123456@tcp(localhost:3306)/pink
maxOpenConns: 20
maxIdleConns: 10

log:
fileName: pink.log
Expand Down
4 changes: 3 additions & 1 deletion conf/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ type AppConf struct {
DialTimeout int64
}
Mysql struct {
DSN string
DSN string
MaxOpenConns int
MaxIdleConns int
}
Log struct {
FileName string
Expand Down
8 changes: 6 additions & 2 deletions db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ func NewDB(app *conf.AppConf) *DB {
panic(err)
}

db.SetMaxOpenConns(20)
db.SetMaxIdleConns(10)
if err = db.Ping(); err != nil {
panic(err)
}

db.SetMaxOpenConns(app.Mysql.MaxOpenConns)
db.SetMaxIdleConns(app.Mysql.MaxIdleConns)
return &DB{DS: db}
}
3 changes: 3 additions & 0 deletions db/repository/execute_snapshot_his_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ func (repo *ExecuteSnapshotHisRepository) SearchExecuteSnapshotHisByPage(request
if err != nil {
return make([]*model.ExecuteSnapshotHis, 0), err
}
defer rows.Close()

records := make([]*model.ExecuteSnapshotHis, 0)

Expand Down Expand Up @@ -167,6 +168,8 @@ func (repo *ExecuteSnapshotHisRepository) SearchExecuteSnapshotHisByCount(reques
return 0, err
}

defer rows.Close()

count := int64(0)
if rows.Next() {
err = rows.Scan(&count)
Expand Down

0 comments on commit eb8b82e

Please sign in to comment.