From 046f7d0d7b1fdc9a6a7c74c93dd1374f05bffbbe Mon Sep 17 00:00:00 2001 From: Pavel Shevaev Date: Wed, 26 Oct 2022 18:51:14 +0300 Subject: [PATCH] Adding some comments --- db.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/db.go b/db.go index 7916b18..49a9b6b 100644 --- a/db.go +++ b/db.go @@ -11,10 +11,6 @@ import ( "git.bit5.ru/backend/res_tracker" ) -const ( - ChunkSizeForIN = 50000 -) - type Settings struct { Host, Port, User, Pass, Name, Prefix, Params string Driver string @@ -45,6 +41,9 @@ func GetDBC(logger *colog.CoLog, s Settings) *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 { if dbc._con == nil { driver := dbc.s.Driver @@ -52,9 +51,9 @@ func (dbc *DBC) con() *dbr.Connection { driver = "mysql" } //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) }