mirror of
https://github.com/injoyai/tdx.git
synced 2025-11-26 21:25:35 +08:00
细节优化
This commit is contained in:
20
manage.go
20
manage.go
@@ -15,8 +15,11 @@ func NewManage(cfg *ManageConfig, op ...client.Option) (*Manage, error) {
|
|||||||
if len(cfg.Hosts) == 0 {
|
if len(cfg.Hosts) == 0 {
|
||||||
cfg.Hosts = Hosts
|
cfg.Hosts = Hosts
|
||||||
}
|
}
|
||||||
if cfg.Dir == "" {
|
if cfg.CodesDir == "" {
|
||||||
cfg.Dir = "./data/"
|
cfg.CodesDir = "./data/database"
|
||||||
|
}
|
||||||
|
if cfg.WorkdayDir == "" {
|
||||||
|
cfg.WorkdayDir = "./data/database"
|
||||||
}
|
}
|
||||||
|
|
||||||
//连接池
|
//连接池
|
||||||
@@ -33,18 +36,18 @@ func NewManage(cfg *ManageConfig, op ...client.Option) (*Manage, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
codesClient.Wait.SetTimeout(time.Second * 5)
|
codesClient.Wait.SetTimeout(time.Second * 5)
|
||||||
codes, err := NewCodes(codesClient, filepath.Join(cfg.Dir, "database/codes.db"))
|
codes, err := NewCodes(codesClient, filepath.Join(cfg.CodesDir, "codes.db"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
///工作日
|
//工作日
|
||||||
workdayClient, err := DialHosts(cfg.Hosts, op...)
|
workdayClient, err := DialHosts(cfg.Hosts, op...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
workdayClient.Wait.SetTimeout(time.Second * 5)
|
workdayClient.Wait.SetTimeout(time.Second * 5)
|
||||||
workday, err := NewWorkday(workdayClient, filepath.Join(cfg.Dir, "database/codes.db"))
|
workday, err := NewWorkday(workdayClient, filepath.Join(cfg.WorkdayDir, "workday.db"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -76,7 +79,8 @@ func (this *Manage) AddWorkdayTask(spec string, f func(m *Manage)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ManageConfig struct {
|
type ManageConfig struct {
|
||||||
Hosts []string //服务端IP
|
Hosts []string //服务端IP
|
||||||
Number int //客户端数量
|
Number int //客户端数量
|
||||||
Dir string //数据位置
|
CodesDir string //代码数据库位置
|
||||||
|
WorkdayDir string //工作日数据库位置
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user