2
0

Add ConnStr getter to Pool and Conn structs.

This commit is contained in:
georgysavva
2020-05-16 18:10:29 +03:00
parent 1b54d15e93
commit a62de87342
5 changed files with 29 additions and 3 deletions
+5
View File
@@ -69,6 +69,7 @@ func (cr *connResource) getPoolRows(c *Conn, r pgx.Rows) *poolRows {
type Pool struct {
p *puddle.Pool
connStr string
afterConnect func(context.Context, *pgx.Conn) error
beforeAcquire func(context.Context, *pgx.Conn) bool
afterRelease func(*pgx.Conn) bool
@@ -141,6 +142,7 @@ func ConnectConfig(ctx context.Context, config *Config) (*Pool, error) {
}
p := &Pool{
connStr: config.ConnConfig.ConnStr,
afterConnect: config.AfterConnect,
beforeAcquire: config.BeforeAcquire,
afterRelease: config.AfterRelease,
@@ -369,6 +371,9 @@ func (p *Pool) AcquireAllIdle(ctx context.Context) []*Conn {
return conns
}
// ConnStr returns the connection string that was used to initialize this pool.
func (p *Pool) ConnStr() string { return p.connStr }
func (p *Pool) Stat() *Stat {
return &Stat{s: p.p.Stat()}
}