Initial commit
Build & Push / build (push) Canceled after 0s

This commit is contained in:
2026-08-05 19:31:35 +03:00
commit a33fa24e99
272 changed files with 40566 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
package postgres
import (
"context"
"fmt"
"github.com/jackc/pgx/v5/pgxpool"
"github.com/rs/zerolog/log"
)
type Config struct {
URL string `envconfig:"DB__URL" required:"true"`
}
type Pool struct {
*pgxpool.Pool
}
func New(ctx context.Context, c Config) (*Pool, error) {
cfg, err := pgxpool.ParseConfig(c.URL)
if err != nil {
return nil, fmt.Errorf("pgxpool.ParseConfig: %w", err)
}
pool, err := pgxpool.NewWithConfig(ctx, cfg)
if err != nil {
return nil, fmt.Errorf("pgxpool.NewWithConfig: %w", err)
}
return &Pool{Pool: pool}, nil
}
func (p *Pool) Close() {
p.Pool.Close()
log.Info().Msg("Postgres closed")
}