Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop
This commit is contained in:
		
						commit
						a401d1e4c9
					
				| @ -10,4 +10,8 @@ type Config struct { | ||||
| 	SourceMysql    string | ||||
| 	Auth           types.Auth | ||||
| 	SourceRabbitMq string | ||||
| 	BLMService     struct { | ||||
| 		Version string | ||||
| 		Urls    []string | ||||
| 	} | ||||
| } | ||||
|  | ||||
| @ -48,12 +48,21 @@ func (l *TestAiLogic) TestAi(req *types.TestAiReq, userinfo *auth.UserInfo) (res | ||||
| 			logx.Error("测试异常:", err) | ||||
| 		} | ||||
| 	}() | ||||
| 	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() | ||||
| 	errChan := make(chan string) | ||||
| 	w := sync.WaitGroup{} | ||||
| 	b := -1 | ||||
| 	for i := 0; i < req.Num; i++ { | ||||
| 		w.Add(1) | ||||
| 		go func() { | ||||
| 		b++ | ||||
| 		if b > lenAiHost-1 { | ||||
| 			b = 0 | ||||
| 		} | ||||
| 		go func(hostIndex int) { | ||||
| 			defer func() { | ||||
| 				if err := recover(); err != nil { | ||||
| 					logx.Error("测试异常2:", err) | ||||
| @ -67,8 +76,9 @@ func (l *TestAiLogic) TestAi(req *types.TestAiReq, userinfo *auth.UserInfo) (res | ||||
| 				return | ||||
| 			} | ||||
| 			var resultBLM constants.BLMServiceUrlResult | ||||
| 			logx.Info("正在请求:" + l.svcCtx.Config.BLMService.Urls[hostIndex]) | ||||
| 			err := curl.NewClient(l.ctx, &curl.Config{ | ||||
| 				BaseUrl:        "http://ai.fusen.3718.cn:8999", | ||||
| 				BaseUrl:        l.svcCtx.Config.BLMService.Urls[hostIndex], | ||||
| 				Url:            constants.BLMServiceUrlLogoCombine, | ||||
| 				RequireTimeout: time.Second * 15, | ||||
| 			}).PostJson(postMap, &resultBLM) | ||||
| @ -76,7 +86,7 @@ func (l *TestAiLogic) TestAi(req *types.TestAiReq, userinfo *auth.UserInfo) (res | ||||
| 				errChan <- err.Error() | ||||
| 				return | ||||
| 			} | ||||
| 		}() | ||||
| 		}(b) | ||||
| 	} | ||||
| 	go func() { | ||||
| 		w.Wait() | ||||
|  | ||||
| @ -34,10 +34,11 @@ type renderProcessor struct { | ||||
| // 云渲染属性 | ||||
| type extendRenderProperty struct { | ||||
| 	renderChan          chan websocket_data.RenderImageReqMsg //渲染消息入口的缓冲队列 | ||||
| 	renderCtx           context.Context                       //渲染控制上下文(用于切换模板标签/颜色取消之前发送的不相同的任务) | ||||
| 	renderCtx           context.Context                       //渲染控制上下文(用于切换模板标签/颜色/logo取消之前发送的不相同的任务) | ||||
| 	renderCtxCancelFunc context.CancelFunc                    //渲染控制上下文取消方法 | ||||
| 	selectColorIndex    int                                   //选择的颜色索引 | ||||
| 	templateTag         string                                //模板标签 | ||||
| 	selectColorIndex    int                                   //选择的颜色索引(用于标记连接当前连接选择的颜色) | ||||
| 	templateTag         string                                //模板标签 (用于标记连接当前连接选择的模板标签) | ||||
| 	Logo                string                                //logo地址 (用于标记连接当前连接选择的logo) | ||||
| } | ||||
| 
 | ||||
| // 处理分发到这里的数据 | ||||
| @ -49,10 +50,22 @@ func (r *renderProcessor) allocationMessage(w *wsConnectItem, data []byte) { | ||||
| 		logx.Error("invalid format of websocket render image message", err) | ||||
| 		return | ||||
| 	} | ||||
| 	if renderImageData.RenderData.TemplateTag != w.extendRenderProperty.templateTag || renderImageData.RenderData.TemplateTagColor.SelectedColorIndex != w.extendRenderProperty.selectColorIndex { | ||||
| 		//赋值 | ||||
| 	//颜色/模板标签/logo变更 | ||||
| 	ifCancelOldCtx := false | ||||
| 	if renderImageData.RenderData.TemplateTag != w.extendRenderProperty.templateTag { | ||||
| 		ifCancelOldCtx = true | ||||
| 	} | ||||
| 	if renderImageData.RenderData.TemplateTagColor.SelectedColorIndex != w.extendRenderProperty.selectColorIndex { | ||||
| 		ifCancelOldCtx = true | ||||
| 	} | ||||
| 	if renderImageData.RenderData.Logo != w.extendRenderProperty.Logo { | ||||
| 		ifCancelOldCtx = true | ||||
| 	} | ||||
| 	if ifCancelOldCtx { | ||||
| 		//赋值新的 | ||||
| 		w.extendRenderProperty.templateTag = renderImageData.RenderData.TemplateTag | ||||
| 		w.extendRenderProperty.selectColorIndex = renderImageData.RenderData.TemplateTagColor.SelectedColorIndex | ||||
| 		w.extendRenderProperty.Logo = renderImageData.RenderData.Logo | ||||
| 		//让之前的失效 | ||||
| 		w.extendRenderProperty.renderCtxCancelFunc() | ||||
| 		//重新赋值 | ||||
| @ -94,6 +107,10 @@ func (w *wsConnectItem) consumeRenderImageData() { | ||||
| 				//logx.Info("颜色不一致,丢弃消息") | ||||
| 				continue | ||||
| 			} | ||||
| 			//logo不一样 | ||||
| 			if data.RenderData.Logo != w.extendRenderProperty.Logo { | ||||
| 				continue | ||||
| 			} | ||||
| 			limitChan <- struct{}{} | ||||
| 			go func(d websocket_data.RenderImageReqMsg) { | ||||
| 				defer func() { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user