Skip to content

Commit

Permalink
Reduce max connections
Browse files Browse the repository at this point in the history
  • Loading branch information
AchoArnold committed Feb 5, 2025
1 parent f865791 commit b290b64
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions api/pkg/di/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,14 @@ func (container *Container) DB() (db *gorm.DB) {
}
container.db = db

sqlDB, err := db.DB()
if err != nil {
container.logger.Fatal(stacktrace.Propagate(err, "cannot get sql.DB from GORM"))
}

sqlDB.SetMaxOpenConns(2)
sqlDB.SetConnMaxLifetime(time.Hour)

if err = db.Use(tracing.NewPlugin()); err != nil {
container.logger.Fatal(stacktrace.Propagate(err, "cannot use GORM tracing plugin"))
}
Expand Down

0 comments on commit b290b64

Please sign in to comment.