创建任务增加重复注册的检测

This commit is contained in:
白茶清欢 2022-06-23 15:36:55 +08:00
parent eb9cb4b6e2
commit 30b6fa4c46

View File

@ -9,6 +9,7 @@ package task
import (
"context"
"fmt"
"sync"
)
@ -48,6 +49,9 @@ func (d *dispatch) Register(taskInstanceList ...ITask) error {
if nil == taskInstance {
continue
}
if _, exist := d.taskTable[taskInstance.Name()]; exist {
return fmt.Errorf("%s 任务重复注册! ", taskInstance.Name())
}
d.taskTable[taskInstance.Name()] = taskInstance
}
return nil