Commit ef19c1cd authored by vicotor's avatar vicotor

add log

parent e840deaa
...@@ -142,38 +142,43 @@ func (n *Node) Loop(idx int) { ...@@ -142,38 +142,43 @@ func (n *Node) Loop(idx int) {
client.Close() client.Close()
return return
case task := <-taskCh: case t := <-taskCh:
log.WithField("task", task).Info("get task") go func(task *odysseus.TaskContent) {
for { l := log.WithField("task-id", task.TaskId)
worker, err := PopWorker(n.rdb) l.WithField("task", task).Info("get task")
if err == ErrNoWorker { for {
result := &odysseus.TaskResponse{ worker, err := PopWorker(n.rdb)
TaskUuid: task.TaskUuid, if err == ErrNoWorker {
TaskUid: task.TaskUid, result := &odysseus.TaskResponse{
TaskFee: task.TaskFee, TaskUuid: task.TaskUuid,
TaskIsSucceed: false, TaskUid: task.TaskUid,
TaskError: err.Error(), TaskFee: task.TaskFee,
TaskIsSucceed: false,
TaskError: err.Error(),
}
l.WithError(err).Error("pop worker failed")
postReceipt(task, result, err)
err = postResult(task, result)
if err != nil {
l.WithError(err).Error("post task result failed")
}
break
} }
postReceipt(task, result, err)
err = postResult(task, result)
if err != nil { if err != nil {
log.WithError(err).Error("post task result failed") l.WithError(err).Error("pop worker failed")
continue
}
err = DispatchTask(worker, task)
if err != nil {
l.WithError(err).Error("dispatch task failed")
continue
} else {
l.WithField("task-id", task.TaskId).Info("dispatch task success")
break
} }
break
}
if err != nil {
log.WithError(err).Error("pop worker failed")
continue
}
err = DispatchTask(worker, task)
if err != nil {
log.WithError(err).Error("dispatch task failed")
continue
} else {
break
} }
} }(t)
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment