创建任务增加重复注册的检测
This commit is contained in:
parent
eb9cb4b6e2
commit
30b6fa4c46
4
task.go
4
task.go
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user