init post-service

This commit is contained in:
2023-09-27 16:17:47 +01:00
parent e0bd8ef953
commit 0341a938fd
31 changed files with 5666 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
package postgres
import (
"context"
"github.com/rs/zerolog/log"
"github.com/jackc/pgx/v5/pgxpool"
"github.com/hexolan/panels/post-service/internal"
)
func NewPostgresInterface(ctx context.Context, cfg internal.Config) *pgxpool.Pool {
db, err := pgxpool.New(ctx, cfg.GetPostgresURL())
if err != nil {
log.Panic().Err(err).Caller().Msg("")
}
err = db.Ping(ctx)
if err != nil {
log.Warn().Err(err).Msg("failed Postgres ping")
}
return db
}