package pgconfig

import "github.com/jackc/pgx/v5/pgxpool"

func (c *DatabaseConfig) PoolConfig() (*pgxpool.Config, error) {
	config, err := pgxpool.ParseConfig(c.ConnectionString())
	if err != nil {
		return nil, err
	}
	config.MaxConns = int32(c.MaxConnections)
	config.MaxConnIdleTime = c.MaxIdleTime
	config.MaxConnLifetime = c.ConnMaxLifetime
	return config, nil
}
