-
Notifications
You must be signed in to change notification settings - Fork 12k
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
(feat) support max connection setting for database configuration #7520
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! But this code could be simplify a bit.
pkg/services/sqlstore/sqlstore.go
Outdated
@@ -177,6 +198,18 @@ func LoadConfig() { | |||
DbCfg.Host = sec.Key("host").String() | |||
DbCfg.Name = sec.Key("name").String() | |||
DbCfg.User = sec.Key("user").String() | |||
DbCfg.MaxConn, err = sec.Key("max_conn").Int() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use .MustInt(0)
instead. Reduce the amount of code needed to read the setting. 0 is the default value anyway :)
pkg/services/sqlstore/sqlstore.go
Outdated
if err != nil { | ||
return nil, err | ||
} else { | ||
if DbCfg.MaxConn != 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This if statement is kinda of redundant. xorm will ignore any connection setting that is 0. So just pass in the DbCfg.MaxConn value. Same for MaxOpenConn
and MaxIdleConn
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, didn't know that, thanks for the information!
fixed |
Merged! Thank you for contributing! :) |
Fix #7427