diff --git a/config/config.go b/config/config.go index 11005b9..59da1cf 100644 --- a/config/config.go +++ b/config/config.go @@ -67,6 +67,7 @@ func initializeDefaults() { viper.SetDefault("database.postgres.user", "postgres") viper.SetDefault("database.postgres.pass", "REPLACE_ME") viper.SetDefault("database.postgres.db", "postgres") + viper.SetDefault("database.postgres.maxconns", 20) viper.SetDefault("storage.type", "s3") viper.SetDefault("storage.bucket", "smr") diff --git a/db/ent.go b/db/ent.go index ee71b11..f23f5c4 100644 --- a/db/ent.go +++ b/db/ent.go @@ -46,6 +46,7 @@ func WithDB(ctx context.Context) (context.Context, error) { } poolConfig.ConnConfig.Tracer = otelpgx.NewTracer() + poolConfig.MaxConns = viper.GetInt32("database.postgres.maxconns") pool, err := pgxpool.NewWithConfig(ctx, poolConfig) if err != nil {