add GetSecDsn to get config description
This commit is contained in:
parent
bf3cd9bc27
commit
34d1b513ba
@ -29,6 +29,15 @@ type Config struct {
|
||||
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 {
|
||||
// Addrs is a slice with known Sentinel addresses.
|
||||
Addrs []string
|
||||
|
Loading…
Reference in New Issue
Block a user