working on ron-example

This commit is contained in:
2024-11-20 23:09:25 +01:00
parent ea5d85bd19
commit 4f108e1b05
25 changed files with 627 additions and 147 deletions
+23
View File
@@ -0,0 +1,23 @@
package config
import (
"context"
"github.com/jackc/pgx/v5/pgxpool"
"log/slog"
)
func NewPostgresPool(dataSource string) *pgxpool.Pool {
dbPool, err := pgxpool.New(context.Background(), dataSource)
if err != nil {
slog.Error("error connecting to database", "error", err)
panic(err)
}
if err := dbPool.Ping(context.Background()); err != nil {
slog.Error("error pinging database, maybe incorrect datasource", "error", err)
panic(err)
}
slog.Info("connected to database")
return dbPool
}