introduce databse connection pooling and harden RowSet operations

This commit is contained in:
amy
2026-11-12 14:25:11 -07:00
parent ec50f048a1
commit 630d129bb5
10 changed files with 97 additions and 21 deletions
+16
View File
@@ -121,6 +121,12 @@ type AmConfig struct {
User string `yaml:"user"`
Password string `yaml:"password"`
DatabaseName string `yaml:"databaseName"`
Pooling struct {
MaxOpen int `yaml:"maxOpen"`
MaxIdle int `yaml:"maxIdle"`
MaxIdleTime int `yaml:"maxIdleTime"`
MaxLifetime int `yaml:"maxLifetime"`
} `yaml:"pooling"`
} `yaml:"database"`
Defaults struct {
Language string `yaml:"language"`
@@ -391,6 +397,16 @@ func SetupConfig() {
GlobalConfig.baseDir = ""
}
// Error-check values.
if GlobalConfig.Database.Pooling.MaxOpen < 0 {
panic("maximum database connections must not be less than zero")
} else if GlobalConfig.Database.Pooling.MaxOpen == 0 {
log.Warn("WARNING: database connections unlimited - server may crash under heavy load")
}
if GlobalConfig.Database.Pooling.MaxIdle < 0 {
panic("maximum idle database connections must not be less than zero")
}
// Compute additional values.
if CommandLine.Debug {
GlobalComputedConfig.DebugMode = true
+5
View File
@@ -46,6 +46,11 @@ database:
user: "amsdb"
password: "x00yes2k"
databaseName: "amsterdam"
pooling:
maxOpen: 100
maxIdle: 10
maxIdleTime: -1
maxLifetime: -1
defaults:
language: "en-US"
timezone: "America/Denver"