Skip to content

Commit 72ce58d

Browse files
committed
fix: limit max db connections
1 parent d419374 commit 72ce58d

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

config/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ func initializeDefaults() {
6767
viper.SetDefault("database.postgres.user", "postgres")
6868
viper.SetDefault("database.postgres.pass", "REPLACE_ME")
6969
viper.SetDefault("database.postgres.db", "postgres")
70+
viper.SetDefault("database.postgres.maxconns", 20)
7071

7172
viper.SetDefault("storage.type", "s3")
7273
viper.SetDefault("storage.bucket", "smr")

db/ent.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ func WithDB(ctx context.Context) (context.Context, error) {
4646
}
4747

4848
poolConfig.ConnConfig.Tracer = otelpgx.NewTracer()
49+
poolConfig.MaxConns = viper.GetInt32("database.postgres.maxconns")
4950

5051
pool, err := pgxpool.NewWithConfig(ctx, poolConfig)
5152
if err != nil {

0 commit comments

Comments
 (0)