Skip to content

Commit

Permalink
Updated the way postgres is connected
Browse files Browse the repository at this point in the history
  • Loading branch information
kpachhai committed Jun 25, 2024
1 parent 234c099 commit c212176
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ func main() {
// Retry mechanism for PostgreSQL connection
var db *sql.DB
for i := 0; i < 10; i++ {
db, err = sql.Open("postgres", fmt.Sprintf("host=%s port=%d user=%s password=%s dbname=%s sslmode=%s",
config.PostgresHost, config.PostgresPort, config.PostgresUser, config.PostgresPassword, config.PostgresDBName, config.PostgresSSLMode))
connStr := fmt.Sprintf("host=%s port=%d user=%s password=%s dbname=%s sslmode=%s",
config.PostgresHost, config.PostgresPort, config.PostgresUser, config.PostgresPassword, config.PostgresDBName, config.PostgresSSLMode)
db, err = sql.Open("postgres", connStr)
if err != nil {
log.Warn("Error opening database", zap.Error(err))
time.Sleep(5 * time.Second)
Expand Down

0 comments on commit c212176

Please sign in to comment.