Skip to content

Commit

Permalink
Add conn max lifetime
Browse files Browse the repository at this point in the history
  • Loading branch information
perrito666 committed Aug 4, 2018
1 parent fe32670 commit 0e993da
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions db/connection/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type Information struct {
User string
Password string
QueryExecTimeout *time.Duration //optionally set the maximum time a query can take to execute
ConnMaxLifetime *time.Duration

TLSConfig *tls.Config // config for TLS connection -- nil disables TLS
UseFallbackTLS bool // Try FallbackTLSConfig if connecting with TLSConfig fails. Used for preferring TLS, but allowing unencrypted, or vice-versa
Expand Down
3 changes: 3 additions & 0 deletions db/postgrespq/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ func (c *Connector) Open(ci *connection.Information) (connection.DB, error) {
if err != nil {
return nil, errors.Wrap(err, "connecting to postgres database")
}
if ci.ConnMaxLifetime != nil {
conn.SetConnMaxLifetime(*ci.ConnMaxLifetime)
}
return &DB{
conn: conn,
logger: conLogger,
Expand Down

0 comments on commit 0e993da

Please sign in to comment.