Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
MKCLOS
Core Development Platform
coreospackage
Commits
a49c3b69
Commit
a49c3b69
authored
7 years ago
by
Sandeep S. Shewalkar
Browse files
Options
Downloads
Plain Diff
Merge branch 'MYSQL_CONFIG_SSS' into 'master'
max open connections and Set Max Idle Conns See merge request
!22
parents
0ab19f65
75c5aa92
Branches
Branches containing commit
Tags
ver1.2
1 merge request
!22
max open connections and Set Max Idle Conns
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dalhelper/dalMySQL.go
+21
-3
dalhelper/dalMySQL.go
with
21 additions
and
3 deletions
dalhelper/dalMySQL.go
+
21
−
3
View file @
a49c3b69
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets