Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
ai-api-mgr
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Odysseus
ai-api-mgr
Commits
705b5847
Commit
705b5847
authored
Mar 12, 2024
by
Cloud User
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
debug async api
parent
03b35c35
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
47 deletions
+8
-47
main.go
main.go
+8
-47
No files found.
main.go
View file @
705b5847
...
...
@@ -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
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment