add GetSecDsn to get config description

This commit is contained in:
bryan 2025-04-08 08:44:20 +08:00
parent bf3cd9bc27
commit 34d1b513ba

View File

@ -29,6 +29,15 @@ type Config struct {
IdleTimeout *int `toml:"idle_timeout"` //空闲超时时间 IdleTimeout *int `toml:"idle_timeout"` //空闲超时时间
} }
func GetSecDsn(cfg Config) (dsn string) {
if cfg.Master != "" {
dsn += fmt.Sprintf("mode=redis address=%s", cfg.Master)
} else if cfg.MasterName != "" {
dsn += fmt.Sprintf("mode=sentinel address=%s mastername=%s", cfg.Sentinels, cfg.MasterName)
}
return dsn
}
type Sentinel struct { type Sentinel struct {
// Addrs is a slice with known Sentinel addresses. // Addrs is a slice with known Sentinel addresses.
Addrs []string Addrs []string