jackc / pgx

PostgreSQL driver and toolkit for Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

stdlib/GetPoolConnector: Before/AfterAcquire

zekth opened this issue · comments

In this commit: 1885648

this was removed:

func OptionBeforeAcquire(ba func(context.Context, *pgxpool.Pool) error) OptionOpenDB {
	return func(c *connector) {
		c.BeforeAcquire = ba
	}
}

// OptionAfterAcquire provides a callback for after acquire. Used only if db is opened with *pgxpool.Pool.
func OptionAfterAcquire(aa func(context.Context, *pgxpool.Conn) error) OptionOpenDB {
	return func(c *connector) {
		c.AfterAcquire = aa
	}
}

What's the rational for it? Is there hopes to have this back?
Would it be possible to have also AfterRelease ?

You can set this callbacks right inside your pgxpool.Pool. See BeforeAcquire and AfterRelease in pgxpool.Config.

Ok my bad i thought it was removed seeing the commits. Thanks