Skip to content

Commit

Permalink
Database: Drop registerDriverOnce variable
Browse files Browse the repository at this point in the history
  • Loading branch information
yhabteab committed Mar 25, 2024
1 parent 811df51 commit 7b3f0ed
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions pkg/config/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,9 @@ import (
"net/url"
"strconv"
"strings"
"sync"
"time"
)

var registerDriverOnce sync.Once

// Database defines database client configuration.
type Database struct {
Type string `yaml:"type" default:"mysql"`
Expand All @@ -38,10 +35,6 @@ type Database struct {
// Open prepares the DSN string and driver configuration,
// calls sqlx.Open, but returns *icingadb.DB.
func (d *Database) Open(logger *logging.Logger) (*icingadb.DB, error) {
registerDriverOnce.Do(func() {
icingadb.Register(logger)
})

var db *sqlx.DB
switch d.Type {
case "mysql":
Expand Down Expand Up @@ -78,6 +71,8 @@ func (d *Database) Open(logger *logging.Logger) (*icingadb.DB, error) {
}
}

icingadb.Register(logger)

c, err := mysql.NewConnector(config)
if err != nil {
return nil, errors.Wrap(err, "can't open mysql database")
Expand Down

0 comments on commit 7b3f0ed

Please sign in to comment.