Your Question
Hi guys.
Please how to achieve the following without downgrading to github.com/jackc/pgx/v5
implementation level. I.e. just by means of gorm.io/driver/postgres
and gorm.io/gorm
import (
"github.com/jackc/pgx/v5"
"github.com/jackc/pgx/v5/stdlib"
"gorm.io/driver/postgres"
"gorm.io/gorm"
)
...
db, err := gorm.Open(
postgres.New(postgres.Config{
Conn: stdlib.OpenDB(
*config,
stdlib.OptionAfterConnect(func(ctx context.Context, c *pgx.Conn) error {
// handle whatever new connection
return nil
}),
),
}),
)
I've tried both to write a custom Plugin
and to override postgres.Dialector
still each of them triggers Initialize
only once instead of per each new connection.
So what would be the solution to handle every single new established connection in the pool?
The document you expected this should be explained
Expected answer
Available option to achieve intended or a feature request if it is not achievable currently.
Thank you