Skip to content

Commit f0222da

Browse files
committed
Limit max number of connections to 7
1 parent 83697bf commit f0222da

File tree

2 files changed

+8747
-3019
lines changed

2 files changed

+8747
-3019
lines changed

api/pkg/di/container.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,18 @@ func (container *Container) YugaByteDB() (db *gorm.DB) {
225225
if err != nil {
226226
container.logger.Fatal(err)
227227
}
228+
228229
if err = db.Use(tracing.NewPlugin()); err != nil {
229230
container.logger.Fatal(stacktrace.Propagate(err, "cannot use GORM tracing plugin"))
230231
}
231232

233+
sql, err := db.DB()
234+
if err != nil {
235+
container.logger.Fatal(err)
236+
}
237+
238+
sql.SetMaxOpenConns(7)
239+
232240
container.logger.Debug(fmt.Sprintf("Running migrations for yugabyte [%T]", db))
233241
if err = db.AutoMigrate(&entities.Heartbeat{}); err != nil {
234242
container.logger.Fatal(stacktrace.Propagate(err, fmt.Sprintf("cannot migrate %T", &entities.Heartbeat{})))

0 commit comments

Comments
 (0)