Commit 705b5847 authored by Cloud User's avatar Cloud User

debug async api

parent 03b35c35
......@@ -927,6 +927,13 @@ func main() {
}
if res, ok := getAsyncRes(taskId); ok {
baseAttributes := []slog.Attr{}
baseAttributes = append(baseAttributes, slog.String(TaskIdAtrr, taskId))
newAttributes := append(baseAttributes, slog.Int("resAsPb.TaskResultCode", int(res.TaskResultCode)), slog.String("TaskResultHeader", string(res.TaskResultHeader)))
slog.LogAttrs(c.UserContext(), slog.LevelInfo, "getAsyncRes", newAttributes...)
return syncOrAsyncReturn(c, res, taskId)
}
......@@ -1176,55 +1183,9 @@ func syncModeF(c *fiber.Ctx, taskid string) error {
baseAttributes = append(baseAttributes, slog.String(TaskIdAtrr, taskid))
newAttributes := append(baseAttributes, slog.Int("resAsPb.TaskResultCode", int(resAsPb.TaskResultCode)), slog.String("TaskResultHeader", string(resAsPb.TaskResultHeader)))
slog.LogAttrs(c.UserContext(), slog.LevelInfo, "new Api or JWT reuqest", newAttributes...)
slog.LogAttrs(c.UserContext(), slog.LevelInfo, "syncModeF", newAttributes...)
return syncOrAsyncReturn(c, resAsPb, taskid)
//slog.Debug("resAsPb.TaskResultHeader", "resAsPb.TaskResultHeader", resAsPb.TaskResultHeader)
// if resAsPb.TaskResultHeader != nil {
// if len(resAsPb.TaskResultHeader) != 0 {
// headers := make(map[string][]string)
// if err := json.Unmarshal(resAsPb.TaskResultHeader, &headers); err != nil {
// slog.LogAttrs(context.Background(), slog.LevelError, "syncModeF", append([]slog.Attr{}, slog.String(TaskIdAtrr, taskid), slog.String("json.Unmarshal", err.Error()))...)
// //slog.Error("syncModeF", "json.Unmarshal(resAsPb.TaskResultHeader", err.Error())
// return c.SendString(fmt.Sprintf("json.Unmarshal(resAsPb.TaskResultHeader error: %v", err.Error()))
// }
// for k, vs := range headers {
// for _, v := range vs {
// if k == "Content-Encoding" {
// c.Response().Header.SetContentEncoding(v)
// }
// if k == "Content-Type" {
// c.Response().Header.SetContentType(v)
// }
// }
// }
// }
// }
// if resAsPb.TaskIsSucceed {
// return c.Send(resAsPb.GetTaskResultBody())
// }
// //fmt.Println("syncMode-------------", syncMode)
// resAsJson := ResponseJson{
// TaskId: resAsPb.TaskId,
// TaskResult: resAsPb.GetTaskResultBody(),
// TaskUid: resAsPb.TaskUid,
// TaskFee: resAsPb.TaskFee,
// IsSuccess: resAsPb.TaskIsSucceed,
// TaskError: resAsPb.TaskError,
// }
// return c.JSON(resAsJson)
}
func syncOrAsyncReturn(c *fiber.Ctx, resAsPb pbUpstream.TaskResponse, reqTaskId string) error {
......
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