mirror of
https://github.com/yanislav-igonin/micrach
synced 2024-12-22 14:22:33 +03:00
27 lines
398 B
Go
27 lines
398 B
Go
package db
|
|
|
|
import (
|
|
"context"
|
|
"log"
|
|
|
|
Config "micrach/config"
|
|
|
|
"github.com/jackc/pgx/v4/pgxpool"
|
|
)
|
|
|
|
var Pool *pgxpool.Pool
|
|
|
|
func Init() {
|
|
var err error
|
|
Pool, err = pgxpool.Connect(context.TODO(), Config.Db.Url)
|
|
if err != nil {
|
|
log.Println("database - offline")
|
|
log.Panicln(err)
|
|
}
|
|
|
|
// TODO: take from config from env var
|
|
Pool.Config().MaxConns = 5
|
|
|
|
log.Println("database - online")
|
|
}
|