GetPoolConnector creates a new driver.Connector from the given *pgxpool.Pool. By using this be sure to set the maximum idle connections of the *sql.DB created with this connector to zero since they must be managed from the *pgxpool.Pool. This is required to avoid acquiring all the connections from t
(pool *pgxpool.Pool, opts ...OptionOpenDB)
| 212 | // *pgxpool.Pool. This is required to avoid acquiring all the connections from the pgxpool and starving any direct |
| 213 | // users of the pgxpool. |
| 214 | func GetPoolConnector(pool *pgxpool.Pool, opts ...OptionOpenDB) driver.Connector { |
| 215 | c := connector{ |
| 216 | pool: pool, |
| 217 | ResetSession: func(context.Context, *pgx.Conn) error { return nil }, // noop reset session by default |
| 218 | driver: pgxDriver, |
| 219 | } |
| 220 | |
| 221 | for _, opt := range opts { |
| 222 | opt(&c) |
| 223 | } |
| 224 | |
| 225 | return c |
| 226 | } |
| 227 | |
| 228 | func OpenDB(config pgx.ConnConfig, opts ...OptionOpenDB) *sql.DB { |
| 229 | c := GetConnector(config, opts...) |