database/config.go

22 lines
725 B
Go
Raw Normal View History

2025-03-27 14:21:57 +01:00
package database
type Config struct {
DSN string `yaml:"dsn" envconfig:"DSN"`
MaxIdleConns int `yaml:"maxIdleConns" envconfig:"MAX_IDLE_CONNS"`
MaxOpenConns int `yaml:"maxOpenConns" envconfig:"MAX_OPEN_CONNS"`
ConnMaxLifetime int `yaml:"connMaxLifetime" envconfig:"CONNS_MAX_LIFE_TIME"`
AutoMigrate bool `yaml:"autoMigrate" envconfig:"AUTO_MIGRATE"`
ShowSql bool `yaml:"showSql" envconfig:"SHOW_SQL"`
}
func NewConfig() *Config {
return &Config{
DSN: "host=localhost user=gate password=gate dbname=gate port=5432 sslmode=disable",
MaxIdleConns: 10,
MaxOpenConns: 20,
ConnMaxLifetime: 3600,
AutoMigrate: false,
ShowSql: false,
}
}