Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
notifications-bot
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
archives
notifications-bot
Commits
29684f45
Commit
29684f45
authored
Jan 5, 2022
by
Jonah Husson
Browse files
Options
Downloads
Patches
Plain Diff
Add idle and open connection params
parent
d6d3aad3
No related branches found
No related tags found
2 merge requests
!32
Release
,
!24
Add idle and open connection params
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
storage/database.go
+16
-0
16 additions, 0 deletions
storage/database.go
with
16 additions
and
0 deletions
storage/database.go
+
16
−
0
View file @
29684f45
...
...
@@ -2,10 +2,12 @@ package storage
import
(
"fmt"
"github.com/pkg/errors"
jww
"github.com/spf13/jwalterweatherman"
"gorm.io/driver/postgres"
"gorm.io/gorm"
"gorm.io/gorm/logger"
"time"
)
// interface declaration for storage methods
...
...
@@ -105,6 +107,20 @@ func newDatabase(username, password, dbName, address,
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
// WARNING: Order is important. Do not change without database testing
models
:=
[]
interface
{}{
&
User
{},
&
Ephemeral
{}}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment