优化http连接池

This commit is contained in:
2025-08-03 14:20:17 +08:00
parent 838430ee2f
commit 84ccaa56de
4 changed files with 45 additions and 13 deletions

View File

@@ -26,8 +26,7 @@ func QueryUploadUrlForTask(ctx context.Context, taskId string) (string, error) {
log.Println("Error creating request:", err)
return "", err
}
client := &http.Client{}
resp, err := client.Do(req)
resp, err := GetAPIClient().Do(req)
if err != nil {
span.SetAttributes(attribute.String("error", err.Error()))
span.SetStatus(codes.Error, "发送请求失败")
@@ -62,8 +61,7 @@ func ReportTaskFailure(ctx context.Context, taskId string) bool {
return false
}
client := &http.Client{}
resp, err := client.Do(req)
resp, err := GetAPIClient().Do(req)
if err != nil {
span.SetAttributes(attribute.String("error", err.Error()))
span.SetStatus(codes.Error, "发送请求失败")
@@ -107,8 +105,7 @@ func ReportTaskSuccess(ctx context.Context, taskId string, file *dto.FileObject)
}
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
resp, err := GetAPIClient().Do(req)
if err != nil {
span.SetAttributes(attribute.String("error", err.Error()))
span.SetStatus(codes.Error, "发送请求失败")