让任务可以提供自身使用设备

This commit is contained in:
2025-11-02 20:47:25 +08:00
parent 4b0be88fca
commit 687c2f12ee
6 changed files with 119 additions and 33 deletions

View File

@@ -14,6 +14,15 @@ type Task interface {
// log: 任务执行的上下文。
// executeErr: 从 Execute 方法返回的原始错误。
OnFailure(executeErr error)
TaskDeviceIDResolver
}
// TaskDeviceIDResolver 定义了从任务配置中解析设备ID的方法
type TaskDeviceIDResolver interface {
// ResolveDeviceIDs 从任务配置中解析并返回所有关联的设备ID列表
// 返回值: uint数组每个字符串代表一个设备ID
ResolveDeviceIDs() ([]uint, error)
}
// TaskFactory 是一个工厂接口,用于根据任务执行日志创建任务实例。