fix
This commit is contained in:
parent
918b5903d7
commit
ae58ebe35a
|
@ -52,8 +52,8 @@ type wsConnectItem struct {
|
||||||
inChan chan []byte //接受消息缓冲通道
|
inChan chan []byte //接受消息缓冲通道
|
||||||
outChan chan []byte //发送回客户端的消息
|
outChan chan []byte //发送回客户端的消息
|
||||||
mutex sync.Mutex
|
mutex sync.Mutex
|
||||||
renderImage map[string]struct{} //需要渲染的图片
|
renderImageTask map[string]struct{} //需要渲染的图片
|
||||||
renderImageControlChan chan renderImageControlChanItem
|
renderImageTaskCtlChan chan renderImageControlChanItem
|
||||||
}
|
}
|
||||||
type renderImageControlChanItem struct {
|
type renderImageControlChanItem struct {
|
||||||
Option int // 0删除 1添加
|
Option int // 0删除 1添加
|
||||||
|
@ -115,8 +115,8 @@ func (l *DataTransferLogic) DataTransfer(svcCtx *svc.ServiceContext, w http.Resp
|
||||||
closeChan: make(chan struct{}, 1),
|
closeChan: make(chan struct{}, 1),
|
||||||
inChan: make(chan []byte, 100),
|
inChan: make(chan []byte, 100),
|
||||||
outChan: make(chan []byte, 100),
|
outChan: make(chan []byte, 100),
|
||||||
renderImage: make(map[string]struct{}),
|
renderImageTask: make(map[string]struct{}),
|
||||||
renderImageControlChan: make(chan renderImageControlChanItem, 100),
|
renderImageTaskCtlChan: make(chan renderImageControlChanItem, 100),
|
||||||
isClose: false,
|
isClose: false,
|
||||||
}
|
}
|
||||||
//保存连接
|
//保存连接
|
||||||
|
@ -183,12 +183,12 @@ func (w *wsConnectItem) operationRenderTask() {
|
||||||
select {
|
select {
|
||||||
case <-w.closeChan:
|
case <-w.closeChan:
|
||||||
return
|
return
|
||||||
case data := <-w.renderImageControlChan:
|
case data := <-w.renderImageTaskCtlChan:
|
||||||
switch data.Option {
|
switch data.Option {
|
||||||
case 0: //删除
|
case 0: //删除
|
||||||
delete(w.renderImage, data.Key)
|
delete(w.renderImageTask, data.Key)
|
||||||
case 1: //新增
|
case 1: //新增
|
||||||
w.renderImage[data.Key] = struct{}{}
|
w.renderImageTask[data.Key] = struct{}{}
|
||||||
default:
|
default:
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,8 +67,8 @@ func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq) (resp *basi
|
||||||
//遍历数据
|
//遍历数据
|
||||||
for _, notifyItem := range req.NotifyList {
|
for _, notifyItem := range req.NotifyList {
|
||||||
renderKey := ws.getRenderImageMapKey(notifyItem.ProductId, notifyItem.SizeId, notifyItem.TemplateId)
|
renderKey := ws.getRenderImageMapKey(notifyItem.ProductId, notifyItem.SizeId, notifyItem.TemplateId)
|
||||||
//查询
|
//查询有无该渲染任务
|
||||||
_, ok = ws.renderImage[renderKey]
|
_, ok = ws.renderImageTask[renderKey]
|
||||||
if !ok {
|
if !ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq) (resp *basi
|
||||||
b, _ := json.Marshal(responseData)
|
b, _ := json.Marshal(responseData)
|
||||||
dataList = append(dataList, b)
|
dataList = append(dataList, b)
|
||||||
//删除对应的需要渲染的图片map
|
//删除对应的需要渲染的图片map
|
||||||
ws.renderImageControlChan <- renderImageControlChanItem{
|
ws.renderImageTaskCtlChan <- renderImageControlChanItem{
|
||||||
Option: 0,
|
Option: 0,
|
||||||
Key: renderKey,
|
Key: renderKey,
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,10 +14,10 @@ func (w *wsConnectItem) SendToCloudRender(data []byte) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
logx.Info("收到请求云渲染图片数据:", renderImageData)
|
logx.Info("收到请求云渲染图片数据:", renderImageData)
|
||||||
//把需要渲染的图片加进去
|
//把需要渲染的图片任务加进去
|
||||||
for _, v := range renderImageData {
|
for _, v := range renderImageData {
|
||||||
key := w.getRenderImageMapKey(v.ProductId, v.SizeId, v.TemplateId)
|
key := w.getRenderImageMapKey(v.ProductId, v.SizeId, v.TemplateId)
|
||||||
w.renderImageControlChan <- renderImageControlChanItem{
|
w.renderImageTaskCtlChan <- renderImageControlChanItem{
|
||||||
Option: 1,
|
Option: 1,
|
||||||
Key: key,
|
Key: key,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user