api: rename connectDB

This commit is contained in:
Adhityaa Chandrasekar 2018-07-24 12:20:14 +05:30
parent 645fad6139
commit 58c011030e
3 changed files with 4 additions and 4 deletions

View File

@ -7,7 +7,7 @@ import (
"time" "time"
) )
func connectDB(retriesLeft int) error { func dbConnect(retriesLeft int) error {
con := os.Getenv("POSTGRES") con := os.Getenv("POSTGRES")
logger.Infof("opening connection to postgres: %s", con) logger.Infof("opening connection to postgres: %s", con)
@ -23,7 +23,7 @@ func connectDB(retriesLeft int) error {
if retriesLeft > 0 { if retriesLeft > 0 {
logger.Errorf("cannot talk to postgres, retrying in 10 seconds (%d attempts left): %v", retriesLeft-1, err) logger.Errorf("cannot talk to postgres, retrying in 10 seconds (%d attempts left): %v", retriesLeft-1, err)
time.Sleep(10 * time.Second) time.Sleep(10 * time.Second)
return connectDB(retriesLeft - 1) return dbConnect(retriesLeft - 1)
} else { } else {
logger.Errorf("cannot talk to postgres, last attempt failed: %v", err) logger.Errorf("cannot talk to postgres, last attempt failed: %v", err)
return err return err

View File

@ -3,7 +3,7 @@ package main
func main() { func main() {
exitIfError(loggerCreate()) exitIfError(loggerCreate())
exitIfError(configParse()) exitIfError(configParse())
exitIfError(connectDB(5)) exitIfError(dbConnect(5))
exitIfError(performMigrations()) exitIfError(performMigrations())
exitIfError(smtpConfigure()) exitIfError(smtpConfigure())
exitIfError(smtpTemplatesLoad()) exitIfError(smtpTemplatesLoad())

View File

@ -68,7 +68,7 @@ func setupTestDatabase() error {
os.Setenv("POSTGRES", "postgres://postgres:postgres@localhost/commento_test?sslmode=disable") os.Setenv("POSTGRES", "postgres://postgres:postgres@localhost/commento_test?sslmode=disable")
} }
if err := connectDB(0); err != nil { if err := dbConnect(0); err != nil {
return err return err
} }