Added generic ping check to probe for active db connection
This commit is contained in:
parent
68400171ac
commit
bdf410d4d1
6
main.go
6
main.go
@ -60,10 +60,8 @@ func Open(dialect string, args ...interface{}) (DB, error) {
|
|||||||
}
|
}
|
||||||
dbSql, err = sql.Open(driver, source)
|
dbSql, err = sql.Open(driver, source)
|
||||||
|
|
||||||
// For some reason, postgres does not throw an connection error.
|
if err == nil {
|
||||||
// Sending a ping request after the connection is made is a quick workaround for this
|
err = db.DB().Ping() // Send a ping to make sure the database connection is alive.
|
||||||
if driver == "postgres" && err == nil {
|
|
||||||
err = db.DB().Ping()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case sqlCommon:
|
case sqlCommon:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user