96 lines
2.6 KiB
Go
96 lines
2.6 KiB
Go
package initialization
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"planA/planB/initialization/config"
|
|
"planA/planB/initialization/dll"
|
|
"planA/planB/initialization/golabl"
|
|
"planA/planB/initialization/kfz"
|
|
"planA/planB/initialization/minIo"
|
|
"planA/planB/initialization/mysql"
|
|
"planA/planB/initialization/platform"
|
|
"planA/planB/initialization/pool"
|
|
"planA/planB/initialization/redis"
|
|
"planA/planB/initialization/speed"
|
|
"planA/planB/initialization/task"
|
|
"planA/planB/initialization/taskType"
|
|
"planA/planB/initialization/title"
|
|
planBType "planA/planB/type"
|
|
planAType "planA/type"
|
|
)
|
|
|
|
// Init 初始化
|
|
func Init(taskId string) error {
|
|
//初始化上下文
|
|
if golabl.Ctx == nil {
|
|
golabl.Ctx = context.Background()
|
|
}
|
|
|
|
// 初始化配置文件
|
|
if configErr := config.GetConfigSetToG(); configErr != nil {
|
|
return fmt.Errorf("初始化配置文件失败:%v", configErr)
|
|
}
|
|
|
|
// 初始化 redis
|
|
if redisErr := redis.LinkRedisSetToG(); redisErr != nil {
|
|
return fmt.Errorf("初始化redis失败: %v", redisErr)
|
|
}
|
|
|
|
// 初始化 mysql
|
|
if mysqlErr := mysql.LikeMysqlSetToG(); mysqlErr != nil {
|
|
return fmt.Errorf("初始化mysql失败: %v", mysqlErr)
|
|
}
|
|
|
|
// 初始化 task
|
|
golabl.Task = &planBType.Task{
|
|
TaskId: taskId,
|
|
Header: &planAType.TaskHeader{},
|
|
Footer: &planAType.TaskFooter{},
|
|
BodyWait: &planAType.TaskBody{},
|
|
BodyOver: &planAType.TaskBody{},
|
|
BodyBackup: &planAType.TaskBody{},
|
|
}
|
|
if taskErr := task.GetTaskHeaderAndFooterSetToG(); taskErr != nil {
|
|
return fmt.Errorf("初始化任务失败: %v", taskErr)
|
|
}
|
|
|
|
// 初始化限速器
|
|
speed.Init()
|
|
|
|
// 初始化 协程池
|
|
if poolErr := pool.CreatePoolToG(); poolErr != nil {
|
|
return fmt.Errorf("初始化协程池失败: %v", poolErr)
|
|
}
|
|
|
|
// 初始化平台
|
|
if platformErr := platform.GetPlatformSetToG(); platformErr != nil {
|
|
return fmt.Errorf("初始化平台失败: %v", platformErr)
|
|
}
|
|
|
|
// 初始化任务类型
|
|
if taskTypeErr := taskType.GetTaskTypeSetToG(); taskTypeErr != nil {
|
|
return fmt.Errorf("初始化任务类型失败: %v", taskTypeErr)
|
|
}
|
|
|
|
// 初始化图片空间
|
|
if newMinIOClientErr := minIo.NewMinIOClient(); newMinIOClientErr != nil {
|
|
return fmt.Errorf("初始化图片空间失败: %v", newMinIOClientErr)
|
|
}
|
|
|
|
// 初始化 DLL
|
|
if dllErr := dll.GetDllSetToG(); dllErr != nil {
|
|
return fmt.Errorf("初始化DLL失败: %v", dllErr)
|
|
}
|
|
|
|
// 初始化 孔夫子公共分类
|
|
if getKfzGoodsCategorySetToGErr := kfz.GetKfzGetCommonCategorySetToG(); getKfzGoodsCategorySetToGErr != nil {
|
|
return fmt.Errorf("初始化孔夫子公共分类失败: %v", getKfzGoodsCategorySetToGErr)
|
|
}
|
|
|
|
//设置窗口标题
|
|
title.SetWinTitle()
|
|
|
|
return nil
|
|
}
|