fix(config): harden database pool settings

This commit is contained in:
2026-05-03 15:04:08 +08:00
parent 774b907da8
commit cec7fa25e3
13 changed files with 105 additions and 43 deletions
+12 -2
View File
@@ -4,6 +4,8 @@ import (
"crypto/tls"
"encoding/json"
"fmt"
"net"
"net/url"
"os"
"strings"
"time"
@@ -53,8 +55,16 @@ type DatabaseConfig struct {
}
func (d DatabaseConfig) DSN() string {
return fmt.Sprintf("postgres://%s:%s@%s:%d/%s?sslmode=%s",
d.User, d.Password, d.Host, d.Port, d.DBName, d.SSLMode)
u := url.URL{
Scheme: "postgres",
User: url.UserPassword(d.User, d.Password),
Host: net.JoinHostPort(d.Host, fmt.Sprintf("%d", d.Port)),
Path: "/" + d.DBName,
}
q := u.Query()
q.Set("sslmode", d.SSLMode)
u.RawQuery = q.Encode()
return u.String()
}
type RedisConfig struct {