mirror of
https://github.com/ditatompel/xmr-remote-nodes.git
synced 2025-01-08 05:52:10 +07:00
Reuse existing db connection (if any)
This commit is contained in:
parent
70372e58ab
commit
5f5ebd81a9
1 changed files with 4 additions and 0 deletions
|
@ -16,6 +16,10 @@ var defaultDB = &DB{}
|
||||||
|
|
||||||
// connect sets the db client of database using configuration
|
// connect sets the db client of database using configuration
|
||||||
func (db *DB) connect(cfg *config.DB) (err error) {
|
func (db *DB) connect(cfg *config.DB) (err error) {
|
||||||
|
if defaultDB.DB != nil {
|
||||||
|
return nil // reuse existing connection if available
|
||||||
|
}
|
||||||
|
|
||||||
dbURI := fmt.Sprintf("%s:%s@(%s:%d)/%s",
|
dbURI := fmt.Sprintf("%s:%s@(%s:%d)/%s",
|
||||||
cfg.User,
|
cfg.User,
|
||||||
cfg.Password,
|
cfg.Password,
|
||||||
|
|
Loading…
Reference in a new issue