-
Notifications
You must be signed in to change notification settings - Fork 0
/
service.go
28 lines (25 loc) · 839 Bytes
/
service.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package redis
import "strings"
type Config struct {
Address string `json:"address"`
Auth string `json:"auth"`
Username string `json:"username"`
CertPath string `json:"certPath"`
}
// New 创建Redis服务
func New(config Config) (service IService, err error) {
if !strings.Contains(config.Address, ",") && !strings.Contains(config.Address, ";") {
service, err = NewRedisService(config.Address, config.Username, config.Auth, config.CertPath)
} else {
var servers []string
if strings.Contains(config.Address, ",") {
servers = strings.Split(config.Address, ",")
} else if strings.Contains(config.Address, ";") {
servers = strings.Split(config.Address, ";")
} else {
servers = []string{config.Address}
}
service, err = NewClusterService(servers, config.Username, config.Auth, config.CertPath)
}
return
}