Files
2026-10-21 13:29:03 +08:00

41 lines
948 B
Go

package callback
import (
"bytes"
"fmt"
"net/http"
"strings"
"lone-services/pkg/utils"
jsoniter "github.com/json-iterator/go"
)
func NotifyPythonService(taskId, subTaskId, folderPath string) error {
if err := MarkTaskProcessing(taskId); err != nil {
return err
}
host := utils.GetConfigString("services.skin_py_analysis_host")
apiPath := utils.GetConfigString("services.skin_py_analysis_path")
if host == utils.StringEmpty || apiPath == utils.StringEmpty {
return fmt.Errorf("python analysis service config empty")
}
url := strings.TrimRight(host, "/") + apiPath
body, _ := jsoniter.Marshal(map[string]interface{}{
"task_id": subTaskId,
"folder_name": folderPath,
})
resp, err := http.Post(url, "application/json", bytes.NewBuffer(body))
if err != nil {
return err
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return fmt.Errorf("python service error: %s", resp.Status)
}
return nil
}