Skip to content

Commit b33fe39

Browse files
nejeckylejohnson
andauthored
fix: confirm initial database connectivity (#314)
- adding db.Ping() call to confirm actual connection to the database to report issues with connectivity as early as possible Co-authored-by: Kyle Johnson <[email protected]>
1 parent ffdd7fd commit b33fe39

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

postgresql/config.go

+4
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,10 @@ func (c *Client) Connect() (*DBConnection, error) {
277277
} else {
278278
db, err = postgres.Open(context.Background(), dsn)
279279
}
280+
281+
if err == nil {
282+
err = db.Ping()
283+
}
280284
if err != nil {
281285
errString := strings.Replace(err.Error(), c.config.Password, "XXXX", 2)
282286
return nil, fmt.Errorf("Error connecting to PostgreSQL server %s (scheme: %s): %s", c.config.Host, c.config.Scheme, errString)

0 commit comments

Comments
 (0)