拆分task包
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
"git.huangwc.com/pig/pig-farm-controller/internal/domain/device"
|
||||
domain_notify "git.huangwc.com/pig/pig-farm-controller/internal/domain/notify"
|
||||
"git.huangwc.com/pig/pig-farm-controller/internal/domain/pig"
|
||||
"git.huangwc.com/pig/pig-farm-controller/internal/domain/scheduler"
|
||||
"git.huangwc.com/pig/pig-farm-controller/internal/domain/task"
|
||||
"git.huangwc.com/pig/pig-farm-controller/internal/domain/token"
|
||||
"git.huangwc.com/pig/pig-farm-controller/internal/infra/config"
|
||||
@@ -125,8 +126,9 @@ type DomainServices struct {
|
||||
PigBatchDomain pig.PigBatchService
|
||||
TimedCollector collection.Collector
|
||||
GeneralDeviceService device.Service
|
||||
AnalysisPlanTaskManager *task.AnalysisPlanTaskManager
|
||||
Scheduler *task.Scheduler
|
||||
taskFactory scheduler.TaskFactory
|
||||
AnalysisPlanTaskManager *scheduler.AnalysisPlanTaskManager
|
||||
Scheduler *scheduler.Scheduler
|
||||
}
|
||||
|
||||
// initDomainServices 初始化所有的领域服务。
|
||||
@@ -148,16 +150,20 @@ func initDomainServices(cfg *config.Config, infra *Infrastructure, logger *logs.
|
||||
)
|
||||
|
||||
// 计划任务管理器
|
||||
analysisPlanTaskManager := task.NewAnalysisPlanTaskManager(infra.Repos.PlanRepo, infra.Repos.PendingTaskRepo, infra.Repos.ExecutionLogRepo, logger)
|
||||
analysisPlanTaskManager := scheduler.NewAnalysisPlanTaskManager(infra.Repos.PlanRepo, infra.Repos.PendingTaskRepo, infra.Repos.ExecutionLogRepo, logger)
|
||||
|
||||
// 任务工厂
|
||||
taskFactory := task.NewTaskFactory(logger, infra.Repos.SensorDataRepo, infra.Repos.DeviceRepo, generalDeviceService)
|
||||
|
||||
// 任务执行器
|
||||
scheduler := task.NewScheduler(
|
||||
planScheduler := scheduler.NewScheduler(
|
||||
infra.Repos.PendingTaskRepo,
|
||||
infra.Repos.ExecutionLogRepo,
|
||||
infra.Repos.DeviceRepo,
|
||||
infra.Repos.SensorDataRepo,
|
||||
infra.Repos.PlanRepo,
|
||||
analysisPlanTaskManager,
|
||||
taskFactory,
|
||||
logger,
|
||||
generalDeviceService,
|
||||
time.Duration(cfg.Task.Interval)*time.Second,
|
||||
@@ -179,7 +185,8 @@ func initDomainServices(cfg *config.Config, infra *Infrastructure, logger *logs.
|
||||
PigBatchDomain: pigBatchDomain,
|
||||
GeneralDeviceService: generalDeviceService,
|
||||
AnalysisPlanTaskManager: analysisPlanTaskManager,
|
||||
Scheduler: scheduler,
|
||||
taskFactory: taskFactory,
|
||||
Scheduler: planScheduler,
|
||||
TimedCollector: timedCollector,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user