This commit is contained in:
laodaming 2023-07-26 15:05:53 +08:00
parent 918b5903d7
commit ae58ebe35a
3 changed files with 12 additions and 12 deletions

View File

@ -52,8 +52,8 @@ type wsConnectItem struct {
inChan chan []byte //接受消息缓冲通道
outChan chan []byte //发送回客户端的消息
mutex sync.Mutex
renderImage map[string]struct{} //需要渲染的图片
renderImageControlChan chan renderImageControlChanItem
renderImageTask map[string]struct{} //需要渲染的图片
renderImageTaskCtlChan chan renderImageControlChanItem
}
type renderImageControlChanItem struct {
Option int // 0删除 1添加
@ -115,8 +115,8 @@ func (l *DataTransferLogic) DataTransfer(svcCtx *svc.ServiceContext, w http.Resp
closeChan: make(chan struct{}, 1),
inChan: make(chan []byte, 100),
outChan: make(chan []byte, 100),
renderImage: make(map[string]struct{}),
renderImageControlChan: make(chan renderImageControlChanItem, 100),
renderImageTask: make(map[string]struct{}),
renderImageTaskCtlChan: make(chan renderImageControlChanItem, 100),
isClose: false,
}
//保存连接
@ -183,12 +183,12 @@ func (w *wsConnectItem) operationRenderTask() {
select {
case <-w.closeChan:
return
case data := <-w.renderImageControlChan:
case data := <-w.renderImageTaskCtlChan:
switch data.Option {
case 0: //删除
delete(w.renderImage, data.Key)
delete(w.renderImageTask, data.Key)
case 1: //新增
w.renderImage[data.Key] = struct{}{}
w.renderImageTask[data.Key] = struct{}{}
default:
}

View File

@ -67,8 +67,8 @@ func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq) (resp *basi
//遍历数据
for _, notifyItem := range req.NotifyList {
renderKey := ws.getRenderImageMapKey(notifyItem.ProductId, notifyItem.SizeId, notifyItem.TemplateId)
//查询
_, ok = ws.renderImage[renderKey]
//查询有无该渲染任务
_, ok = ws.renderImageTask[renderKey]
if !ok {
continue
}
@ -81,7 +81,7 @@ func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq) (resp *basi
b, _ := json.Marshal(responseData)
dataList = append(dataList, b)
//删除对应的需要渲染的图片map
ws.renderImageControlChan <- renderImageControlChanItem{
ws.renderImageTaskCtlChan <- renderImageControlChanItem{
Option: 0,
Key: renderKey,
}

View File

@ -14,10 +14,10 @@ func (w *wsConnectItem) SendToCloudRender(data []byte) {
return
}
logx.Info("收到请求云渲染图片数据:", renderImageData)
//把需要渲染的图片加进去
//把需要渲染的图片任务加进去
for _, v := range renderImageData {
key := w.getRenderImageMapKey(v.ProductId, v.SizeId, v.TemplateId)
w.renderImageControlChan <- renderImageControlChanItem{
w.renderImageTaskCtlChan <- renderImageControlChanItem{
Option: 1,
Key: key,
}