Manage简单兼容DefaultCodes

This commit is contained in:
injoyai
2025-03-18 14:48:02 +08:00
parent 51d8d06fbd
commit b221dbc3e2
2 changed files with 15 additions and 11 deletions

View File

@@ -22,16 +22,9 @@ func NewManage(cfg *ManageConfig, op ...client.Option) (*Manage, error) {
cfg.WorkdayDir = "./data/database"
}
//连接池
p, err := NewPool(func() (*Client, error) {
return DialHosts(cfg.Hosts, op...)
}, cfg.Number)
if err != nil {
return nil, err
}
//代码
codesClient, err := DialHosts(cfg.Hosts, op...)
DefaultCodes = &Codes{}
codesClient, err := DialHostsRandom(cfg.Hosts, op...)
if err != nil {
return nil, err
}
@@ -40,6 +33,15 @@ func NewManage(cfg *ManageConfig, op ...client.Option) (*Manage, error) {
if err != nil {
return nil, err
}
DefaultCodes = codes
//连接池
p, err := NewPool(func() (*Client, error) {
return DialHosts(cfg.Hosts, op...)
}, cfg.Number)
if err != nil {
return nil, err
}
//工作日
workdayClient, err := DialHosts(cfg.Hosts, op...)