增加三种redis初始化方式
This commit is contained in:
parent
bcecf65832
commit
34e12b1350
54
client.go
54
client.go
@ -27,13 +27,63 @@ var (
|
||||
Client ClientInterface
|
||||
)
|
||||
|
||||
func init() {
|
||||
Client = &OwnClient{
|
||||
// InitWithCfgFile 使用配置文件初始化
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 21:24 2022/6/22
|
||||
func InitWithCfgFile(cfgFilePath string) error {
|
||||
c := &OwnClient{
|
||||
lock: &sync.RWMutex{},
|
||||
instanceTable: make(map[string]*RealClient),
|
||||
confTable: make(map[string]*FullConfig),
|
||||
parseErrorFunc: defaultParseError,
|
||||
}
|
||||
if err := c.loadConfig(cfgFilePath); nil != err {
|
||||
return err
|
||||
}
|
||||
Client = c
|
||||
return nil
|
||||
}
|
||||
|
||||
// InitWithCfgDir 使用配置目录初始化
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 21:31 2022/6/22
|
||||
func InitWithCfgDir(cfgDir string) error {
|
||||
c := &OwnClient{
|
||||
lock: &sync.RWMutex{},
|
||||
instanceTable: make(map[string]*RealClient),
|
||||
confTable: make(map[string]*FullConfig),
|
||||
parseErrorFunc: defaultParseError,
|
||||
}
|
||||
if err := c.batchLoadConfig(cfgDir); nil != err {
|
||||
return err
|
||||
}
|
||||
Client = c
|
||||
return nil
|
||||
}
|
||||
|
||||
// InitWithCfgFileList 使用批量的配置文件初始化
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 21:33 2022/6/22
|
||||
func InitWithCfgFileList(cfgFileList []string) error {
|
||||
c := &OwnClient{
|
||||
lock: &sync.RWMutex{},
|
||||
instanceTable: make(map[string]*RealClient),
|
||||
confTable: make(map[string]*FullConfig),
|
||||
parseErrorFunc: defaultParseError,
|
||||
}
|
||||
for _, cfgFilePath := range cfgFileList {
|
||||
if err := c.loadConfig(cfgFilePath); nil != err {
|
||||
return err
|
||||
}
|
||||
}
|
||||
Client = c
|
||||
return nil
|
||||
}
|
||||
|
||||
// defaultParseError ...
|
||||
|
Loading…
Reference in New Issue
Block a user