micrach/db/db.go

27 lines
398 B
Go
Raw Normal View History

2021-08-26 16:16:50 +03:00
package db
import (
"context"
"log"
Config "micrach/config"
"github.com/jackc/pgx/v4/pgxpool"
)
var Pool *pgxpool.Pool
func Init() {
var err error
2021-09-10 19:16:53 +03:00
Pool, err = pgxpool.Connect(context.TODO(), Config.Db.Url)
2021-08-26 16:16:50 +03:00
if err != nil {
log.Println("database - offline")
log.Panicln(err)
}
2021-09-11 17:57:57 +03:00
// TODO: take from config from env var
Pool.Config().MaxConns = 5
2021-08-26 16:16:50 +03:00
log.Println("database - online")
}