Moved min/max number of db connections to config file

This commit is contained in:
Asaf Gartner 2021-04-06 09:10:15 +03:00
parent 490c82940a
commit 470a0e4932
3 changed files with 5 additions and 1 deletions

View File

@ -8,5 +8,7 @@ var Config = HMNConfig{
Hostname: "handmade.local",
Port: 5454,
DbName: "hmn",
MinConn: 2, // Keep these low for dev, high for production
MaxConn: 2,
},
}

View File

@ -29,6 +29,8 @@ type PostgresConfig struct {
Port int
DbName string
LogLevel pgx.LogLevel
MinConn int32
MaxConn int32
}
type AuthConfig struct {

View File

@ -25,7 +25,7 @@ var WebsiteCommand = &cobra.Command{
logging.Info().Msg("Hello, HMN!")
conn := db.NewConnPool(4, 128)
conn := db.NewConnPool(config.Config.Postgres.MinConn, config.Config.Postgres.MaxConn)
server := http.Server{
Addr: config.Config.Addr,