Adjust based on review comments
@@ -11,7 +11,7 @@ import (
"github.com/volatiletech/sqlboiler/boil"
)
-const maxDBConnectAttempts = 10
+const maxDBConnectAttempts = 7
// Handler implements the app database handler.
type Handler interface {
@@ -63,14 +63,14 @@ func (c *Connection) Connect() error {
dsn := MakeDSN(c.params)
c.logger.LogF(monitor.F{"dsn": dsn}).Info("connecting to the DB")
var err error
- var secondsToWait int
var db *sqlx.DB
for i := 0; i < maxDBConnectAttempts; i++ {
db, err = sqlx.Connect(c.dialect, dsn)
if err == nil {
break
}
- secondsToWait = secondsToWait + i + 1
+ secondsToWait := i + 1
+ c.logger.Log().Warning("Database Connection Err: ", err)
c.logger.Log().Warningf("Attempt %d - could not connect to database...retry in %d seconds", i, secondsToWait)
time.Sleep(time.Duration(secondsToWait) * time.Second)
}
