(OraklNode) Consideration for singleton pattern implementation
Closed this issue · 0 comments
nick-bisonai commented
func getPool(ctx context.Context, once *sync.Once) (*pgxpool.Pool, error) {
var err error
connectionString := loadPgsqlConnectionString()
if connectionString == "" {
err = errors.New("DATABASE_URL is not set")
return nil, err
}
once.Do(func() {
pool, err = connectToPgsql(ctx, connectionString)
})
return pool, err
}
currently it keeps calling os.getenv
to retrieve connection string whenever getPool is called,
should it be implemented by also putting err in a global variable?