Manage的Codes和Workday共用一个客户端

This commit is contained in:
injoyai
2025-07-01 16:00:16 +08:00
parent 9269bca388
commit 2e4ecd034c

View File

@@ -25,13 +25,21 @@ func NewManage(cfg *ManageConfig, op ...client.Option) (*Manage, error) {
cfg.Dial = DialDefault
}
//代码
codesClient, err := cfg.Dial(op...)
//通用客户端
commonClient, err := cfg.Dial(op...)
if err != nil {
return nil, err
}
codesClient.Wait.SetTimeout(time.Second * 5)
codes, err := NewCodes(codesClient, cfg.CodesFilename)
commonClient.Wait.SetTimeout(time.Second * 5)
//代码管理
codes, err := NewCodes(commonClient, cfg.CodesFilename)
if err != nil {
return nil, err
}
//工作日管理
workday, err := NewWorkday(commonClient, cfg.WorkdayFileName)
if err != nil {
return nil, err
}
@@ -44,17 +52,6 @@ func NewManage(cfg *ManageConfig, op ...client.Option) (*Manage, error) {
return nil, err
}
//工作日
workdayClient, err := cfg.Dial(op...)
if err != nil {
return nil, err
}
workdayClient.Wait.SetTimeout(time.Second * 5)
workday, err := NewWorkday(workdayClient, cfg.WorkdayFileName)
if err != nil {
return nil, err
}
return &Manage{
Pool: p,
Config: cfg,