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

add max open/idle db connection #169

Merged
merged 2 commits into from
Nov 14, 2024
Merged

Conversation

chinmayb
Copy link
Contributor

@chinmayb chinmayb commented Nov 6, 2024

  • Set DB max open connections & max Idle connection by default

@chinmayb chinmayb requested a review from kd7lxl November 6, 2024 16:52
@chinmayb chinmayb force-pushed the maxDb branch 2 times, most recently from 1fee735 to db62795 Compare November 6, 2024 16:56

{{ if .WithDatabase }}
// setMaxOpenIdleConnection sets the db connection string
func setMaxOpenIdleConnection(db *gorm.DB) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might call it something like configureDBConns().

It would be nice to set the SetConnMaxIdleTime and SetConnMaxLifetime as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

Comment on lines +34 to +35
defaultDatabaseMaxConnLifetime = 30 * time.Minute
defaultDatabaseMaxConnIdleTime = 10 * time.Minute
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kd7lxl Do these defaults look good?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be even shorter without adding significant overhead, but these are good.

@chinmayb chinmayb merged commit 121ccc9 into infobloxopen:master Nov 14, 2024
1 check passed
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.

2 participants