Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow setting connection max lifetime #424

Merged

Conversation

chrisgilmerproj
Copy link
Contributor

I'd like to be able to set the maximum lifetime on a DB connection. My use case is that I'm authenticating to the DB using AWS IAM roles which have tokens that expire every 15 minutes. So my connection shouldn't last longer that that time before I need to generate a new token and a new connection.

I am writing this PR because I can't seem to do this and it seemed easier to contribute back:

if db, ok := connection.Store.(*pop.dB); ok {
  sqlxDB := db.DB
  sqlxDB.SetConnMaxLifetime(10 * time.Minute)
}

@chrisgilmerproj chrisgilmerproj requested a review from a team as a code owner August 23, 2019 23:13
@stanislas-m stanislas-m self-assigned this Aug 24, 2019
@stanislas-m stanislas-m merged commit 55a7e42 into gobuffalo:development Aug 25, 2019
@stanislas-m
Copy link
Member

Thanks!

@stanislas-m stanislas-m added this to the Next milestone Aug 25, 2019
@chrisgilmerproj chrisgilmerproj deleted the set_conn_max_lifetime branch August 26, 2019 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants