core/crm-core/internal/infrastructure/postgres/pool.go
2025-12-27 14:32:00 -03:00

20 lines
400 B
Go

package postgres
import (
"context"
"time"
"github.com/jackc/pgx/v5/pgxpool"
)
func NewPool(ctx context.Context, databaseURL string) (*pgxpool.Pool, error) {
cfg, err := pgxpool.ParseConfig(databaseURL)
if err != nil {
return nil, err
}
cfg.MaxConns = 10
cfg.MinConns = 2
cfg.MaxConnLifetime = time.Hour
cfg.MaxConnIdleTime = 10 * time.Minute
return pgxpool.NewWithConfig(ctx, cfg)
}