Skip to content
Snippets Groups Projects
Commit 92c23bee authored by Jonah Husson's avatar Jonah Husson
Browse files

Merge branch 'release' into jonah/batch-notifs

parents 939d1d97 6534a1b9
No related branches found
No related tags found
2 merge requests!32Release,!25Restructure notification code for batching
...@@ -2,10 +2,12 @@ package storage ...@@ -2,10 +2,12 @@ package storage
import ( import (
"fmt" "fmt"
"github.com/pkg/errors"
jww "github.com/spf13/jwalterweatherman" jww "github.com/spf13/jwalterweatherman"
"gorm.io/driver/postgres" "gorm.io/driver/postgres"
"gorm.io/gorm" "gorm.io/gorm"
"gorm.io/gorm/logger" "gorm.io/gorm/logger"
"time"
) )
// interface declaration for storage methods // interface declaration for storage methods
...@@ -106,6 +108,20 @@ func newDatabase(username, password, dbName, address, ...@@ -106,6 +108,20 @@ func newDatabase(username, password, dbName, address,
return database(mapImpl), nil return database(mapImpl), nil
} }
// Get and configure the internal database ConnPool
sqlDb, err := db.DB()
if err != nil {
return database(&DatabaseImpl{}), errors.Errorf("Unable to configure database connection pool: %+v", err)
}
// SetMaxIdleConns sets the maximum number of connections in the idle connection pool.
sqlDb.SetMaxIdleConns(10)
// SetMaxOpenConns sets the maximum number of open connections to the Database.
sqlDb.SetMaxOpenConns(50)
// SetConnMaxLifetime sets the maximum amount of time a connection may be idle.
sqlDb.SetConnMaxIdleTime(10 * time.Minute)
// SetConnMaxLifetime sets the maximum amount of time a connection may be reused.
sqlDb.SetConnMaxLifetime(12 * time.Hour)
// Initialize the database schema // Initialize the database schema
// WARNING: Order is important. Do not change without database testing // WARNING: Order is important. Do not change without database testing
models := []interface{}{&User{}, &Ephemeral{}} models := []interface{}{&User{}, &Ephemeral{}}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment