mirror of
https://github.com/hibiken/asynq.git
synced 2025-01-13 08:23:37 +08:00
fix Result lack of key issue
This commit is contained in:
parent
db74324535
commit
a247371366
14
server.go
14
server.go
@ -239,10 +239,14 @@ func (p TaskStateProber) Changed(out map[string]interface{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p TaskStateProber) Result(state base.TaskState, raw *base.TaskInfo) (key string, data interface{}) {
|
func (p TaskStateProber) Result(state base.TaskState, raw *base.TaskInfo) (key string, data interface{}) {
|
||||||
if state == base.TaskStateCompleted {
|
defer func() {
|
||||||
data = *newTaskInfo(raw.Message, raw.State, raw.NextProcessAt, raw.Result)
|
if len(key) == 0 {
|
||||||
return
|
key = "task"
|
||||||
}
|
}
|
||||||
|
if data == nil {
|
||||||
|
data = *newTaskInfo(raw.Message, raw.State, raw.NextProcessAt, raw.Result)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
probers := p.Probers
|
probers := p.Probers
|
||||||
if len(probers) == 0 {
|
if len(probers) == 0 {
|
||||||
@ -259,9 +263,7 @@ func (p TaskStateProber) Result(state base.TaskState, raw *base.TaskInfo) (key s
|
|||||||
switch key {
|
switch key {
|
||||||
case "next":
|
case "next":
|
||||||
data = raw.NextProcessAt
|
data = raw.NextProcessAt
|
||||||
case "task":
|
case "result":
|
||||||
data = *newTaskInfo(raw.Message, raw.State, raw.NextProcessAt, raw.Result)
|
|
||||||
default:
|
|
||||||
if len(raw.Result) > 0 {
|
if len(raw.Result) > 0 {
|
||||||
data = raw.Result
|
data = raw.Result
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user