forked from mtusi2026/mtusi2026lab2
Реализация на 5
This commit is contained in:
@@ -33,7 +33,7 @@ func addMaxConnectionsToCfg(cfg any, poolCfg *pgxpool.Config) {
|
||||
}
|
||||
}
|
||||
|
||||
func New(cfg MigrationConfig, afterConnect ...AfterConnect) (*pgxpool.Pool, error) {
|
||||
func New(cfg MigrationConfig, afterConnect ...AfterConnect) *pgxpool.Pool {
|
||||
lvl := getLevelFromConfig(cfg)
|
||||
|
||||
if len(afterConnect) == 0 {
|
||||
@@ -43,7 +43,7 @@ func New(cfg MigrationConfig, afterConnect ...AfterConnect) (*pgxpool.Pool, erro
|
||||
poolConfig, err := pgxpool.ParseConfig(cfg.GetURI())
|
||||
if err != nil {
|
||||
slog.Error("failed to parse postgres config", "error", err)
|
||||
return nil, errParseConfig
|
||||
panic(err)
|
||||
}
|
||||
|
||||
addMaxConnectionsToCfg(cfg, poolConfig)
|
||||
@@ -61,11 +61,11 @@ func New(cfg MigrationConfig, afterConnect ...AfterConnect) (*pgxpool.Pool, erro
|
||||
pool, err := pgxpool.NewWithConfig(context.Background(), poolConfig)
|
||||
if err != nil {
|
||||
slog.Error("failed to create postgres pool", "error", err)
|
||||
return nil, errCreatingPool
|
||||
panic(err)
|
||||
}
|
||||
|
||||
slog.Info("successfully connected to postgres pool")
|
||||
return pool, nil
|
||||
return pool
|
||||
}
|
||||
|
||||
func load(afterConnects ...AfterConnect) func(ctx context.Context, conn *pgx.Conn) error {
|
||||
|
||||
Reference in New Issue
Block a user