Skip to content

Commit

Permalink
Configures limit in Postgres connection pool
Browse files Browse the repository at this point in the history
  • Loading branch information
cuducos committed Nov 3, 2024
1 parent b9593fe commit 357465d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions db/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"path/filepath"
"strings"
"text/template"
"time"

"github.com/jackc/pgx/v5"
"github.com/jackc/pgx/v5/pgxpool"
Expand Down Expand Up @@ -183,6 +184,9 @@ func NewPostgreSQL(uri, schema string, nr *newrelic.Application) (PostgreSQL, er
if err != nil {
return PostgreSQL{}, fmt.Errorf("could not create database config: %w", err)
}
cfg.MaxConns = 128
cfg.MaxConnIdleTime = 5 * time.Minute
cfg.MaxConnLifetime = 30 * time.Minute
if nr != nil {
cfg.ConnConfig.Tracer = nrpgx5.NewTracer()
}
Expand Down

0 comments on commit 357465d

Please sign in to comment.