mirror of
https://github.com/hexolan/panels.git
synced 2026-03-26 12:40:21 +00:00
init post-service
This commit is contained in:
24
services/post-service/internal/postgres/postgres.go
Normal file
24
services/post-service/internal/postgres/postgres.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user