Skip to content

Commit

Permalink
fix: limit max db connections
Browse files Browse the repository at this point in the history
  • Loading branch information
Vilsol committed Oct 12, 2024
1 parent d419374 commit 72ce58d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
1 change: 1 addition & 0 deletions db/ent.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 72ce58d

Please sign in to comment.