fedilogue/db.go
Farhan Khan 1adaba8322 retrying connections + logging prefix
this is because some hosting providers throttle rapid new connections
regex additions
2021-01-14 19:51:42 +00:00

18 lines
440 B
Go

package main
import (
"context"
"fmt"
"github.com/jackc/pgx/pgxpool"
)
func getDbPool() *pgxpool.Pool {
// Setup Database
dbURI := fmt.Sprintf("postgres://%s:%s@%s:%d/fedilogue", settings.Database.Username, settings.Database.Password, settings.Database.Host, settings.Database.Port)
pool, err := pgxpool.Connect(context.Background(), dbURI)
if err != nil {
logFatal.Fatal("Unable to connect to database:", err)
}
return pool
}