Commit a49c3b69 authored by Sandeep S. Shewalkar's avatar Sandeep S. Shewalkar
Browse files

Merge branch 'MYSQL_CONFIG_SSS' into 'master'

max open connections and Set Max Idle Conns

See merge request !22
parents 0ab19f65 75c5aa92
Branches
Tags ver1.2
1 merge request!22max open connections and Set Max Idle Conns
Showing with 21 additions and 3 deletions
......@@ -2,8 +2,10 @@ package dalhelper
import (
"sync"
_ "github.com/go-sql-driver/mysql"
"time"
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/coreospackage/confighelper"
_ "github.com/go-sql-driver/mysql"
"github.com/gocraft/dbr"
)
......@@ -13,6 +15,20 @@ var sqlConnection *dbr.Connection
var connectionError error
var sqlOnce sync.Once
//GetSQLConnection to db
// func GetSQLConnection() (*dbr.Connection, error) {
// sqlOnce.Do(func() {
// // create a connection db(e.g. "postgres", "mysql", or "sqlite3")
// connection, err := dbr.Open("mysql", confighelper.GetConfig("MysqlDSN"), nil)
// if err != nil {
// connectionError = err
// }
// // connection.SetMaxIdleConns(10)
// // connection.SetMaxOpenConns(5)
// sqlConnection = connection
// })
// return sqlConnection, connectionError
// }
//GetSQLConnection to db
func GetSQLConnection() (*dbr.Connection, error) {
sqlOnce.Do(func() {
......@@ -21,8 +37,10 @@ func GetSQLConnection() (*dbr.Connection, error) {
if err != nil {
connectionError = err
}
// connection.SetMaxIdleConns(10)
// connection.SetMaxOpenConns(5)
connection.SetMaxIdleConns(100)
connection.SetMaxOpenConns(5000)
duration := 3 * 24 * time.Hour
connection.SetConnMaxLifetime(duration)
sqlConnection = connection
})
return sqlConnection, connectionError
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment