mirror of
https://github.com/fleetdm/fleet
synced 2026-05-23 08:58:41 +00:00
Add flags for configuring MySQL connection pooling limits (#1672)
This commit is contained in:
parent
6442736c12
commit
9c52bed855
2 changed files with 9 additions and 0 deletions
|
|
@ -25,6 +25,8 @@ type MysqlConfig struct {
|
|||
TLSCA string `yaml:"tls_ca"`
|
||||
TLSServerName string `yaml:"tls_server_name"`
|
||||
TLSConfig string `yaml:"tls_config"` //tls=customValue in DSN
|
||||
MaxOpenConns int `yaml:"max_open_conns"`
|
||||
MaxIdleConns int `yaml:"max_idle_conns"`
|
||||
}
|
||||
|
||||
// RedisConfig defines configs related to Redis
|
||||
|
|
@ -121,6 +123,8 @@ func (man Manager) addConfigs() {
|
|||
"MySQL TLS server name")
|
||||
man.addConfigString("mysql.tls_config", "",
|
||||
"MySQL TLS config value. Use skip-verify, true, false or custom key.")
|
||||
man.addConfigInt("mysql.max_open_conns", 50, "MySQL maximum open connection handles.")
|
||||
man.addConfigInt("mysql.max_idle_conns", 50, "MySQL maximum idle connection handles.")
|
||||
|
||||
// Redis
|
||||
man.addConfigString("redis.address", "localhost:6379",
|
||||
|
|
@ -200,6 +204,8 @@ func (man Manager) LoadConfig() KolideConfig {
|
|||
TLSCA: man.getConfigString("mysql.tls_ca"),
|
||||
TLSServerName: man.getConfigString("mysql.tls_server_name"),
|
||||
TLSConfig: man.getConfigString("mysql.tls_config"),
|
||||
MaxOpenConns: man.getConfigInt("mysql.max_open_conns"),
|
||||
MaxIdleConns: man.getConfigInt("mysql.max_idle_conns"),
|
||||
},
|
||||
Redis: RedisConfig{
|
||||
Address: man.getConfigString("redis.address"),
|
||||
|
|
|
|||
|
|
@ -73,6 +73,9 @@ func New(config config.MysqlConfig, c clock.Clock, opts ...DBOption) (*Datastore
|
|||
return nil, err
|
||||
}
|
||||
|
||||
db.SetMaxIdleConns(config.MaxIdleConns)
|
||||
db.SetMaxOpenConns(config.MaxOpenConns)
|
||||
|
||||
var dbError error
|
||||
for attempt := 0; attempt < options.maxAttempts; attempt++ {
|
||||
dbError = db.Ping()
|
||||
|
|
|
|||
Loading…
Reference in a new issue