moved mysql connection pool config to openConection func

This commit is contained in:
Yosyp Buchma 2023-09-20 13:13:50 +03:00
parent f472becd89
commit dd8d043cb8
2 changed files with 5 additions and 4 deletions

View file

@ -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)

View file

@ -28,10 +28,6 @@ ORDER BY table_name;
return nil, fmt.Errorf("failed to query %s metadata result: %w", tableType, err)
}
const maxConns = 32
db.SetMaxOpenConns(maxConns)
db.SetMaxIdleConns(maxConns)
wg := errgroup.Group{}
for i := 0; i < len(tables); i++ {
i := i