Add optional params
in DB config to accept arbitrary Postgres params. Closes #1016.
This commit is contained in:
parent
1f693b80f7
commit
5d4f1ea0ad
2 changed files with 5 additions and 1 deletions
|
@ -248,6 +248,7 @@ func initDB() *sqlx.DB {
|
||||||
Password string `koanf:"password"`
|
Password string `koanf:"password"`
|
||||||
DBName string `koanf:"database"`
|
DBName string `koanf:"database"`
|
||||||
SSLMode string `koanf:"ssl_mode"`
|
SSLMode string `koanf:"ssl_mode"`
|
||||||
|
Params string `koanf:"params"`
|
||||||
MaxOpen int `koanf:"max_open"`
|
MaxOpen int `koanf:"max_open"`
|
||||||
MaxIdle int `koanf:"max_idle"`
|
MaxIdle int `koanf:"max_idle"`
|
||||||
MaxLifetime time.Duration `koanf:"max_lifetime"`
|
MaxLifetime time.Duration `koanf:"max_lifetime"`
|
||||||
|
@ -258,7 +259,7 @@ func initDB() *sqlx.DB {
|
||||||
|
|
||||||
lo.Printf("connecting to db: %s:%d/%s", c.Host, c.Port, c.DBName)
|
lo.Printf("connecting to db: %s:%d/%s", c.Host, c.Port, c.DBName)
|
||||||
db, err := sqlx.Connect("postgres",
|
db, err := sqlx.Connect("postgres",
|
||||||
fmt.Sprintf("host=%s port=%d user=%s password=%s dbname=%s sslmode=%s", c.Host, c.Port, c.User, c.Password, c.DBName, c.SSLMode))
|
fmt.Sprintf("host=%s port=%d user=%s password=%s dbname=%s sslmode=%s %s", c.Host, c.Port, c.User, c.Password, c.DBName, c.SSLMode, c.Params))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
lo.Fatalf("error connecting to DB: %v", err)
|
lo.Fatalf("error connecting to DB: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,3 +26,6 @@ ssl_mode = "disable"
|
||||||
max_open = 25
|
max_open = 25
|
||||||
max_idle = 25
|
max_idle = 25
|
||||||
max_lifetime = "300s"
|
max_lifetime = "300s"
|
||||||
|
|
||||||
|
# Optional space separated Postgres DSN params. eg: "application_name=listmonk gssencmode=disable"
|
||||||
|
params = ""
|
||||||
|
|
Loading…
Reference in a new issue