use conn poll url first

This commit is contained in:
Andre Medeiros 2021-07-05 20:37:47 -04:00
parent 9925ce7eb6
commit 06b80b9714
2 changed files with 12 additions and 2 deletions

View file

@ -35,7 +35,12 @@ func main() {
var cfg config var cfg config
db, err := sql.Open("postgres", os.Getenv("DATABASE_URL")) dburl, ok := os.LookupEnv("DATABASE_CONNECTION_POOL_URL")
if !ok {
dburl = os.Getenv("DATABASE_URL")
}
db, err := sql.Open("postgres", dburl)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }

View file

@ -124,7 +124,12 @@ func main() {
rc := reddit.NewClient(os.Getenv("REDDIT_CLIENT_ID"), os.Getenv("REDDIT_CLIENT_SECRET")) rc := reddit.NewClient(os.Getenv("REDDIT_CLIENT_ID"), os.Getenv("REDDIT_CLIENT_SECRET"))
db, err := sql.Open("postgres", os.Getenv("DATABASE_URL")) dburl, ok := os.LookupEnv("DATABASE_CONNECTION_POOL_URL")
if !ok {
dburl = os.Getenv("DATABASE_URL")
}
db, err := sql.Open("postgres", dburl)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }