fix: 任务处理返回信息和错误error对象
This commit is contained in:
@@ -19,10 +19,10 @@ var NewSimple = &Simple{}
|
||||
|
||||
type Simple struct{}
|
||||
|
||||
func (s *Simple) Execute(data any) any {
|
||||
func (s *Simple) Execute(data any) (any, error) {
|
||||
logger.Infof("执行=> %+v ", data)
|
||||
// 实现任务处理逻辑
|
||||
return data
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func TestSimple(t *testing.T) {
|
||||
@@ -68,7 +68,7 @@ type FooProcessor struct {
|
||||
count int
|
||||
}
|
||||
|
||||
func (s *FooProcessor) Execute(data any) any {
|
||||
func (s *FooProcessor) Execute(data any) (any, error) {
|
||||
logger.Infof("执行 %d %d => %+v ", s.count, s.progress, data)
|
||||
s.count++
|
||||
|
||||
@@ -85,7 +85,7 @@ func (s *FooProcessor) Execute(data any) any {
|
||||
// 改变任务进度
|
||||
s.progress = i
|
||||
}
|
||||
return data
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func TestFoo(t *testing.T) {
|
||||
@@ -119,7 +119,7 @@ type BarProcessor struct {
|
||||
count int
|
||||
}
|
||||
|
||||
func (s *BarProcessor) Execute(data any) any {
|
||||
func (s *BarProcessor) Execute(data any) (any, error) {
|
||||
logger.Infof("执行 %d %d => %+v ", s.count, s.progress, data)
|
||||
s.count++
|
||||
|
||||
@@ -145,7 +145,7 @@ func (s *BarProcessor) Execute(data any) any {
|
||||
s.progress = i
|
||||
}
|
||||
|
||||
return data
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func TestBar(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user