Adding some comments

This commit is contained in:
Pavel Shevaev 2022-10-26 18:51:14 +03:00
parent 55ed4966c1
commit 046f7d0d7b
1 changed files with 5 additions and 6 deletions

11
db.go
View File

@ -11,10 +11,6 @@ import (
"git.bit5.ru/backend/res_tracker" "git.bit5.ru/backend/res_tracker"
) )
const (
ChunkSizeForIN = 50000
)
type Settings struct { type Settings struct {
Host, Port, User, Pass, Name, Prefix, Params string Host, Port, User, Pass, Name, Prefix, Params string
Driver string Driver string
@ -45,6 +41,9 @@ func GetDBC(logger *colog.CoLog, s Settings) *DBC {
return dbc return dbc
} }
//NOTE: In its current implementation this method creates a new Pool
// on each connection request. This is subotimal and should be
// addressed in a new version of the package
func (dbc *DBC) con() *dbr.Connection { func (dbc *DBC) con() *dbr.Connection {
if dbc._con == nil { if dbc._con == nil {
driver := dbc.s.Driver driver := dbc.s.Driver
@ -52,9 +51,9 @@ func (dbc *DBC) con() *dbr.Connection {
driver = "mysql" driver = "mysql"
} }
//NOTE: sql.Open(..) doesn't happen to return an error //NOTE: sql.Open(..) doesn't happen to return an error
sqlDb, _ := sql.Open(driver, dbc.s.ConnStr()) pool, _ := sql.Open(driver, dbc.s.ConnStr())
dbc._con = dbr.NewConnection(sqlDb, nil) dbc._con = dbr.NewConnection(pool, nil)
res_tracker.Track(dbc) res_tracker.Track(dbc)
} }