moved mysql connection pool config to openConection func
This commit is contained in:
parent
f472becd89
commit
dd8d043cb8
2 changed files with 5 additions and 4 deletions
|
|
@ -12,6 +12,8 @@ import (
|
|||
mysqldr "github.com/go-sql-driver/mysql"
|
||||
)
|
||||
|
||||
const mysqlMaxConns = 10
|
||||
|
||||
// DBConnection contains MySQL connection details
|
||||
type DBConnection struct {
|
||||
Host string
|
||||
|
|
@ -83,6 +85,9 @@ func openConnection(connectionString string) (*sql.DB, error) {
|
|||
return nil, fmt.Errorf("failed to open mysql connection: %w", err)
|
||||
}
|
||||
|
||||
db.SetMaxOpenConns(mysqlMaxConns)
|
||||
db.SetMaxIdleConns(mysqlMaxConns)
|
||||
|
||||
err = db.Ping()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to ping database: %w", err)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue