fix
This commit is contained in:
parent
a0106e30cc
commit
8cf76c7051
|
@ -10,4 +10,8 @@ type Config struct {
|
||||||
SourceMysql string
|
SourceMysql string
|
||||||
Auth types.Auth
|
Auth types.Auth
|
||||||
SourceRabbitMq string
|
SourceRabbitMq string
|
||||||
|
BLMService struct {
|
||||||
|
Version string
|
||||||
|
Urls []string
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,13 +48,21 @@ func (l *TestAiLogic) TestAi(req *types.TestAiReq, userinfo *auth.UserInfo) (res
|
||||||
logx.Error("测试异常:", err)
|
logx.Error("测试异常:", err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
//lenAiHost := len(l.svcCtx.Config.)
|
lenAiHost := len(l.svcCtx.Config.BLMService.Urls)
|
||||||
|
if lenAiHost == 0 {
|
||||||
|
return resp.SetStatusWithMessage(basic.CodeServiceErr, "ai host list is 0")
|
||||||
|
}
|
||||||
begin := time.Now().UTC().UnixMilli()
|
begin := time.Now().UTC().UnixMilli()
|
||||||
errChan := make(chan string)
|
errChan := make(chan string)
|
||||||
w := sync.WaitGroup{}
|
w := sync.WaitGroup{}
|
||||||
|
b := -1
|
||||||
for i := 0; i < req.Num; i++ {
|
for i := 0; i < req.Num; i++ {
|
||||||
w.Add(1)
|
w.Add(1)
|
||||||
go func() {
|
b++
|
||||||
|
if b > lenAiHost-1 {
|
||||||
|
b = 0
|
||||||
|
}
|
||||||
|
go func(hostIndex int) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := recover(); err != nil {
|
if err := recover(); err != nil {
|
||||||
logx.Error("测试异常2:", err)
|
logx.Error("测试异常2:", err)
|
||||||
|
@ -69,7 +77,7 @@ func (l *TestAiLogic) TestAi(req *types.TestAiReq, userinfo *auth.UserInfo) (res
|
||||||
}
|
}
|
||||||
var resultBLM constants.BLMServiceUrlResult
|
var resultBLM constants.BLMServiceUrlResult
|
||||||
err := curl.NewClient(l.ctx, &curl.Config{
|
err := curl.NewClient(l.ctx, &curl.Config{
|
||||||
BaseUrl: "http://ai.fusen.3718.cn:8999",
|
BaseUrl: l.svcCtx.Config.BLMService.Urls[hostIndex],
|
||||||
Url: constants.BLMServiceUrlLogoCombine,
|
Url: constants.BLMServiceUrlLogoCombine,
|
||||||
RequireTimeout: time.Second * 15,
|
RequireTimeout: time.Second * 15,
|
||||||
}).PostJson(postMap, &resultBLM)
|
}).PostJson(postMap, &resultBLM)
|
||||||
|
@ -77,7 +85,7 @@ func (l *TestAiLogic) TestAi(req *types.TestAiReq, userinfo *auth.UserInfo) (res
|
||||||
errChan <- err.Error()
|
errChan <- err.Error()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}()
|
}(b)
|
||||||
}
|
}
|
||||||
go func() {
|
go func() {
|
||||||
w.Wait()
|
w.Wait()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user