Skip to content

Commit

Permalink
database connection check
Browse files Browse the repository at this point in the history
  • Loading branch information
daviian committed May 20, 2019
1 parent a094d8e commit 1b66859
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion internal/bridge/database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ func Open() (DB, error) {
}

dbConn, err := sql.Open(config.Bridge.DB.Driver, connURL.String())
if err != nil {
return nil, errors.Wrap(err, "could not create db connection pool")
}

return &db{dbConn}, errors.Wrap(err, "could not connect to database server")
if err := dbConn.Ping(); err != nil {
dbConn.Close()
return nil, errors.Wrap(err, "could not connect to database server")
}
return &db{dbConn}, nil
}

0 comments on commit 1b66859

Please sign in to comment.