From c54f804ebf7eee97e95aee56f417eec10d5aa000 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 21 Sep 2023 14:55:23 +0800 Subject: [PATCH 01/13] fix --- server/shopping-cart/internal/logic/getcartslogic.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/shopping-cart/internal/logic/getcartslogic.go b/server/shopping-cart/internal/logic/getcartslogic.go index 0c498c9f..96a53135 100644 --- a/server/shopping-cart/internal/logic/getcartslogic.go +++ b/server/shopping-cart/internal/logic/getcartslogic.go @@ -132,15 +132,16 @@ func (l *GetCartsLogic) GetCarts(req *types.GetCartsReq, userinfo *auth.UserInfo stepQuantityList := make([]int64, 0, 20) tmpMinBuyNum := *sizePrice.MinBuyNum for tmpMinBuyNum < (int64(stepNum[len(stepNum)-1]) + 5) { - //阶梯数 tmpQuantity := tmpMinBuyNum * (*sizePrice.EachBoxNum) stepQuantityList = append(stepQuantityList, tmpQuantity) tmpMinBuyNum++ } + //尺寸信息 sizeCapacity := snapShot.SizeInfo.Capacity if sizeInfo, ok := mapSize[*cart.SizeId]; ok { sizeCapacity = *sizeInfo.Capacity } + //配件信息 fittingName := snapShot.FittingInfo.FittingName if fittingInfo, ok := mapModel[*cart.FittingId]; ok { fittingName = *fittingInfo.Name @@ -148,7 +149,9 @@ func (l *GetCartsLogic) GetCarts(req *types.GetCartsReq, userinfo *auth.UserInfo productCover := "" //产品封面图 productName := snapShot.ProductInfo.ProductName productSn := snapShot.ProductInfo.ProductSn + //产品封面图资源元数据 var productCoverMetadata interface{} + //产品信息 if productInfo, ok := mapProduct[*cart.ProductId]; ok { productCover = *productInfo.Cover productName = *productInfo.Title From e87dd4f80082c9bc0350fa07552088ded2afc23f Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 21 Sep 2023 15:40:56 +0800 Subject: [PATCH 02/13] fix --- .../internal/logic/getcartslogic.go | 23 ++++++---------- server/shopping-cart/internal/types/types.go | 27 ++++++++++--------- server_api/shopping-cart.api | 27 ++++++++++--------- 3 files changed, 36 insertions(+), 41 deletions(-) diff --git a/server/shopping-cart/internal/logic/getcartslogic.go b/server/shopping-cart/internal/logic/getcartslogic.go index 96a53135..c0b3fe7d 100644 --- a/server/shopping-cart/internal/logic/getcartslogic.go +++ b/server/shopping-cart/internal/logic/getcartslogic.go @@ -123,19 +123,11 @@ func (l *GetCartsLogic) GetCarts(req *types.GetCartsReq, userinfo *auth.UserInfo } } //计算价格 - itemPrice, totalPrice, stepNum, _, err := l.svcCtx.Repositories.NewShoppingCart.CaculateCartPrice(*cart.PurchaseQuantity, &sizePrice, fittingPrice) + itemPrice, totalPrice, _, _, err := l.svcCtx.Repositories.NewShoppingCart.CaculateCartPrice(*cart.PurchaseQuantity, &sizePrice, fittingPrice) if err != nil { logx.Error(err) return resp.SetStatusWithMessage(basic.CodeServiceErr, err.Error()) } - //获取阶梯数量 - stepQuantityList := make([]int64, 0, 20) - tmpMinBuyNum := *sizePrice.MinBuyNum - for tmpMinBuyNum < (int64(stepNum[len(stepNum)-1]) + 5) { - tmpQuantity := tmpMinBuyNum * (*sizePrice.EachBoxNum) - stepQuantityList = append(stepQuantityList, tmpQuantity) - tmpMinBuyNum++ - } //尺寸信息 sizeCapacity := snapShot.SizeInfo.Capacity if sizeInfo, ok := mapSize[*cart.SizeId]; ok { @@ -190,12 +182,13 @@ func (l *GetCartsLogic) GetCarts(req *types.GetCartsReq, userinfo *auth.UserInfo Qrcode: snapShot.UserDiyInformation.Qrcode, Slogan: snapShot.UserDiyInformation.Slogan, }, - PurchaseQuantity: *cart.PurchaseQuantity, - StepNum: stepQuantityList, - IsInvalid: false, - InvalidDescription: "", - IsHighlyCustomized: *cart.IsHighlyCustomized > 0, - IsSelected: *cart.IsSelected > 0, + PurchaseQuantity: *cart.PurchaseQuantity, + MinPurchaseQuantity: *sizePrice.EachBoxNum * (*sizePrice.MinBuyNum), + StepPurchaseQuantity: *sizePrice.EachBoxNum, + IsInvalid: false, + InvalidDescription: "", + IsHighlyCustomized: *cart.IsHighlyCustomized > 0, + IsSelected: *cart.IsSelected > 0, } //是否有失效的 if description, ok := mapCartChange[cart.Id]; ok { diff --git a/server/shopping-cart/internal/types/types.go b/server/shopping-cart/internal/types/types.go index ed87d501..b30ae342 100644 --- a/server/shopping-cart/internal/types/types.go +++ b/server/shopping-cart/internal/types/types.go @@ -39,19 +39,20 @@ type GetCartsRsp struct { } type CartItem struct { - CartId int64 `json:"cart_id"` - ProductInfo ProductInfo `json:"product_info"` //产品信息 - SizeInfo SizeInfo `json:"size_info"` //尺寸信息 - FittingInfo FittingInfo `json:"fitting_info"` //配件信息 - ItemPrice string `json:"item_price"` //单价 - TotalPrice string `json:"total_price"` //单价X数量=总价 - DiyInformation DiyInformation `json:"diy_information"` //diy信息 - StepNum []int64 `json:"step_num"` //阶梯数量 - PurchaseQuantity int64 `json:"purchase_quantity"` //当前购买数量 - IsHighlyCustomized bool `json:"is_highly_customized"` //是否高度定制 - IsInvalid bool `json:"is_invalid"` //是否无效 - InvalidDescription string `json:"invalid_description"` //无效原因 - IsSelected bool `json:"is_selected"` //是否选中 + CartId int64 `json:"cart_id"` + ProductInfo ProductInfo `json:"product_info"` //产品信息 + SizeInfo SizeInfo `json:"size_info"` //尺寸信息 + FittingInfo FittingInfo `json:"fitting_info"` //配件信息 + ItemPrice string `json:"item_price"` //单价 + TotalPrice string `json:"total_price"` //单价X数量=总价 + DiyInformation DiyInformation `json:"diy_information"` //diy信息 + PurchaseQuantity int64 `json:"purchase_quantity"` //当前购买数量 + MinPurchaseQuantity int64 `json:"min_purchase_quantity"` //起购数量 + StepPurchaseQuantity int64 `json:"step_purchase_quantity"` //购买加或者减少步进量 + IsHighlyCustomized bool `json:"is_highly_customized"` //是否高度定制 + IsInvalid bool `json:"is_invalid"` //是否无效 + InvalidDescription string `json:"invalid_description"` //无效原因 + IsSelected bool `json:"is_selected"` //是否选中 } type ProductInfo struct { diff --git a/server_api/shopping-cart.api b/server_api/shopping-cart.api index 5ab4f029..5b73ac76 100644 --- a/server_api/shopping-cart.api +++ b/server_api/shopping-cart.api @@ -56,19 +56,20 @@ type GetCartsRsp { CartList []CartItem `json:"cart_list"` } type CartItem { - CartId int64 `json:"cart_id"` - ProductInfo ProductInfo `json:"product_info"` //产品信息 - SizeInfo SizeInfo `json:"size_info"` //尺寸信息 - FittingInfo FittingInfo `json:"fitting_info"` //配件信息 - ItemPrice string `json:"item_price"` //单价 - TotalPrice string `json:"total_price"` //单价X数量=总价 - DiyInformation DiyInformation `json:"diy_information"` //diy信息 - StepNum []int64 `json:"step_num"` //阶梯数量 - PurchaseQuantity int64 `json:"purchase_quantity"` //当前购买数量 - IsHighlyCustomized bool `json:"is_highly_customized"` //是否高度定制 - IsInvalid bool `json:"is_invalid"` //是否无效 - InvalidDescription string `json:"invalid_description"` //无效原因 - IsSelected bool `json:"is_selected"` //是否选中 + CartId int64 `json:"cart_id"` + ProductInfo ProductInfo `json:"product_info"` //产品信息 + SizeInfo SizeInfo `json:"size_info"` //尺寸信息 + FittingInfo FittingInfo `json:"fitting_info"` //配件信息 + ItemPrice string `json:"item_price"` //单价 + TotalPrice string `json:"total_price"` //单价X数量=总价 + DiyInformation DiyInformation `json:"diy_information"` //diy信息 + PurchaseQuantity int64 `json:"purchase_quantity"` //当前购买数量 + MinPurchaseQuantity int64 `json:"min_purchase_quantity"` //起购数量 + StepPurchaseQuantity int64 `json:"step_purchase_quantity"` //购买加或者减少步进量 + IsHighlyCustomized bool `json:"is_highly_customized"` //是否高度定制 + IsInvalid bool `json:"is_invalid"` //是否无效 + InvalidDescription string `json:"invalid_description"` //无效原因 + IsSelected bool `json:"is_selected"` //是否选中 } type ProductInfo { ProductId int64 `json:"product_id"` //产品id From 15b278f78286cff7cd12843c66db8956ba5c9d00 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 21 Sep 2023 15:57:01 +0800 Subject: [PATCH 03/13] fix --- server/shopping-cart/internal/logic/calculatecartpricelogic.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/shopping-cart/internal/logic/calculatecartpricelogic.go b/server/shopping-cart/internal/logic/calculatecartpricelogic.go index 41e496ea..81772b57 100644 --- a/server/shopping-cart/internal/logic/calculatecartpricelogic.go +++ b/server/shopping-cart/internal/logic/calculatecartpricelogic.go @@ -134,11 +134,11 @@ func (l *CalculateCartPriceLogic) CalculateCartPrice(req *types.CalculateCartPri }) updData := &gmodel.FsShoppingCart{ PurchaseQuantity: &reqPurchaseQuantity, + IsSelected: &isSelected, } //如果是选中则累加总价 if isSelected == 1 { subTotalPrice += totalPrice - updData.IsSelected = &isSelected } //更新购物车购买数量 if err = shoppingCartModel.Update(l.ctx, cart.Id, userinfo.UserId, updData); err != nil { From 82e510194879676f522ba4a94cff2c6ac28652d2 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 21 Sep 2023 16:10:49 +0800 Subject: [PATCH 04/13] fix --- server/shopping-cart/internal/logic/getcartslogic.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/shopping-cart/internal/logic/getcartslogic.go b/server/shopping-cart/internal/logic/getcartslogic.go index c0b3fe7d..290740a0 100644 --- a/server/shopping-cart/internal/logic/getcartslogic.go +++ b/server/shopping-cart/internal/logic/getcartslogic.go @@ -185,8 +185,6 @@ func (l *GetCartsLogic) GetCarts(req *types.GetCartsReq, userinfo *auth.UserInfo PurchaseQuantity: *cart.PurchaseQuantity, MinPurchaseQuantity: *sizePrice.EachBoxNum * (*sizePrice.MinBuyNum), StepPurchaseQuantity: *sizePrice.EachBoxNum, - IsInvalid: false, - InvalidDescription: "", IsHighlyCustomized: *cart.IsHighlyCustomized > 0, IsSelected: *cart.IsSelected > 0, } @@ -194,6 +192,8 @@ func (l *GetCartsLogic) GetCarts(req *types.GetCartsReq, userinfo *auth.UserInfo if description, ok := mapCartChange[cart.Id]; ok { item.IsInvalid = true item.InvalidDescription = description + //失效了返回给前端也是不选中 + item.IsSelected = false } list = append(list, item) } From c06e5da01cacd8210565c6782748820a5959235e Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 21 Sep 2023 16:48:09 +0800 Subject: [PATCH 05/13] fix --- server/websocket/internal/logic/ws_render_image.go | 1 + 1 file changed, 1 insertion(+) diff --git a/server/websocket/internal/logic/ws_render_image.go b/server/websocket/internal/logic/ws_render_image.go index f1ac5270..67e48c9b 100644 --- a/server/websocket/internal/logic/ws_render_image.go +++ b/server/websocket/internal/logic/ws_render_image.go @@ -152,6 +152,7 @@ func (w *wsConnectItem) renderImage(data []byte) { renderImageData.RenderData.Slogan = templateSwitchInfo.MaterialData.Slogan.DefaultValue } }*/ + w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "暂停维护,请稍后", 0, 0, 0, 0, 0, 0, 0) //获取刀版图 combineReq := repositories.LogoCombineReq{ UserId: renderImageData.RenderData.UserId, From 93a69414321e77dcb6d09d0e5fe83ca64b8ee95f Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 21 Sep 2023 16:54:49 +0800 Subject: [PATCH 06/13] fix --- server/websocket/internal/logic/ws_render_image.go | 1 + 1 file changed, 1 insertion(+) diff --git a/server/websocket/internal/logic/ws_render_image.go b/server/websocket/internal/logic/ws_render_image.go index 67e48c9b..1eef99b9 100644 --- a/server/websocket/internal/logic/ws_render_image.go +++ b/server/websocket/internal/logic/ws_render_image.go @@ -153,6 +153,7 @@ func (w *wsConnectItem) renderImage(data []byte) { } }*/ w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "暂停维护,请稍后", 0, 0, 0, 0, 0, 0, 0) + return //获取刀版图 combineReq := repositories.LogoCombineReq{ UserId: renderImageData.RenderData.UserId, From b230d764e0d7fbad9e43bdba575cc1bb13ef4a2b Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 21 Sep 2023 16:58:37 +0800 Subject: [PATCH 07/13] fix --- server/websocket/internal/logic/ws_render_image.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/server/websocket/internal/logic/ws_render_image.go b/server/websocket/internal/logic/ws_render_image.go index 1eef99b9..f1ac5270 100644 --- a/server/websocket/internal/logic/ws_render_image.go +++ b/server/websocket/internal/logic/ws_render_image.go @@ -152,8 +152,6 @@ func (w *wsConnectItem) renderImage(data []byte) { renderImageData.RenderData.Slogan = templateSwitchInfo.MaterialData.Slogan.DefaultValue } }*/ - w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "暂停维护,请稍后", 0, 0, 0, 0, 0, 0, 0) - return //获取刀版图 combineReq := repositories.LogoCombineReq{ UserId: renderImageData.RenderData.UserId, From f7c0d90ab3e6332d5a5e30e0eab1d8cfc0621b7b Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 21 Sep 2023 17:06:12 +0800 Subject: [PATCH 08/13] fix --- server/websocket/internal/logic/datatransferlogic.go | 10 ++-------- server/websocket/internal/logic/ws_render_image.go | 4 +--- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go index ca5d3bb9..974e3bf6 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -67,9 +67,9 @@ var ( //websocket连接存储 mapConnPool = sync.Map{} //每个websocket连接入口缓冲队列长度默认值 - websocketInChanLen = 500 + websocketInChanLen = 50 //每个websocket连接出口缓冲队列长度默认值 - websocketOutChanLen = 500 + websocketOutChanLen = 50 //是否开启debug openDebug = true //允许跨域的origin @@ -400,9 +400,6 @@ func (w *wsConnectItem) sendToOutChan(data []byte) { return case w.outChan <- data: return - case <-time.After(time.Millisecond * 50): //阻塞超过50ms丢弃 - logx.Error("failed to send to out chan,time expired,data:", string(data)) - return } } @@ -413,9 +410,6 @@ func (w *wsConnectItem) sendToInChan(data []byte) { return case w.inChan <- data: return - case <-time.After(time.Millisecond * 200): //200豪秒超时丢弃,说明超过消费速度了 - w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_INCOME_CACHE_QUEUE_OVERFLOW, "send message is too frequent,the message is ignore by system:"+string(data))) - return } } diff --git a/server/websocket/internal/logic/ws_render_image.go b/server/websocket/internal/logic/ws_render_image.go index f1ac5270..41f6e070 100644 --- a/server/websocket/internal/logic/ws_render_image.go +++ b/server/websocket/internal/logic/ws_render_image.go @@ -21,7 +21,7 @@ import ( var ( //每个websocket渲染任务缓冲队列长度默认值 - renderChanLen = 500 + renderChanLen = 20 ) // 渲染处理器 @@ -42,8 +42,6 @@ func (r *renderProcessor) allocationMessage(w *wsConnectItem, data []byte) { return case w.extendRenderProperty.renderChan <- data: //发入到缓冲队列 return - case <-time.After(time.Second * 3): //三秒没进入缓冲队列就丢弃 - return } } From bcbcf0a4b25f8329ad19b296b5f18a5dd376f412 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 21 Sep 2023 17:08:04 +0800 Subject: [PATCH 09/13] fix --- server/websocket/internal/logic/commonnotifylogic.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/websocket/internal/logic/commonnotifylogic.go b/server/websocket/internal/logic/commonnotifylogic.go index c42af9eb..f7ec9b0c 100644 --- a/server/websocket/internal/logic/commonnotifylogic.go +++ b/server/websocket/internal/logic/commonnotifylogic.go @@ -28,7 +28,7 @@ func NewCommonNotifyLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Comm } // 定义公共回调未找到websocket连接时暂存数据缓冲队列 -var commonConnectionNotFoundDataCacheChan = make(chan commonConnectionNotFoundDataCacheChanItem, 2000) +var commonConnectionNotFoundDataCacheChan = make(chan commonConnectionNotFoundDataCacheChanItem, 100) type commonConnectionNotFoundDataCacheChanItem struct { retryTimes int //重回队列次数 From 8a908a4438a1263f110c36f04eaa69ce28ecd11b Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 21 Sep 2023 17:10:56 +0800 Subject: [PATCH 10/13] fix --- server/websocket/internal/logic/ws_render_image.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/websocket/internal/logic/ws_render_image.go b/server/websocket/internal/logic/ws_render_image.go index 41f6e070..36a92f8d 100644 --- a/server/websocket/internal/logic/ws_render_image.go +++ b/server/websocket/internal/logic/ws_render_image.go @@ -36,7 +36,7 @@ type extendRenderProperty struct { // 处理分发到这里的数据 func (r *renderProcessor) allocationMessage(w *wsConnectItem, data []byte) { - //logx.Info("收到渲染任务消息:", string(data)) + logx.Info("开始处理渲染任务消息:", string(data)) select { case <-w.closeChan: //已经关闭 return From e86a8072a5341add52f4c563aca6d034d76977da Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 21 Sep 2023 17:13:31 +0800 Subject: [PATCH 11/13] fix --- server/websocket/internal/logic/datatransferlogic.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go index 974e3bf6..bfa2321d 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -164,8 +164,6 @@ func (l *DataTransferLogic) DataTransfer(w http.ResponseWriter, r *http.Request) go ws.consumeOutChanData() //消费入口数据 go ws.consumeInChanData() - //操作连接中渲染任务的增加/删除 - //go ws.operationRenderTask() //消费渲染缓冲队列 go ws.consumeRenderImageData() //心跳 From 0885c645c3c30275f148904f9ee02a3c44c072eb Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 21 Sep 2023 17:22:22 +0800 Subject: [PATCH 12/13] fix --- server/websocket/internal/logic/ws_render_image.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/websocket/internal/logic/ws_render_image.go b/server/websocket/internal/logic/ws_render_image.go index 36a92f8d..7dcb0863 100644 --- a/server/websocket/internal/logic/ws_render_image.go +++ b/server/websocket/internal/logic/ws_render_image.go @@ -36,7 +36,7 @@ type extendRenderProperty struct { // 处理分发到这里的数据 func (r *renderProcessor) allocationMessage(w *wsConnectItem, data []byte) { - logx.Info("开始处理渲染任务消息:", string(data)) + //logx.Info("开始处理渲染任务消息:", string(data)) select { case <-w.closeChan: //已经关闭 return From 5db1f3f09d2bb7de0dd093f6ae660d596ba6e304 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 21 Sep 2023 17:56:48 +0800 Subject: [PATCH 13/13] fix --- .../internal/logic/commonnotifylogic.go | 4 +--- .../internal/logic/datatransferlogic.go | 7 +++---- .../websocket/internal/logic/ws_render_image.go | 16 +++++----------- .../internal/logic/ws_user_connect_pool.go | 7 ------- 4 files changed, 9 insertions(+), 25 deletions(-) diff --git a/server/websocket/internal/logic/commonnotifylogic.go b/server/websocket/internal/logic/commonnotifylogic.go index f7ec9b0c..ea961822 100644 --- a/server/websocket/internal/logic/commonnotifylogic.go +++ b/server/websocket/internal/logic/commonnotifylogic.go @@ -28,7 +28,7 @@ func NewCommonNotifyLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Comm } // 定义公共回调未找到websocket连接时暂存数据缓冲队列 -var commonConnectionNotFoundDataCacheChan = make(chan commonConnectionNotFoundDataCacheChanItem, 100) +var commonConnectionNotFoundDataCacheChan = make(chan commonConnectionNotFoundDataCacheChanItem, 2000) type commonConnectionNotFoundDataCacheChanItem struct { retryTimes int //重回队列次数 @@ -40,8 +40,6 @@ func pushCommonNotifyCache(data commonConnectionNotFoundDataCacheChanItem) { select { case commonConnectionNotFoundDataCacheChan <- data: return - case <-time.After(time.Millisecond * 50): //超50ms就丢弃 - return } } diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go index bfa2321d..fa7a9258 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -67,9 +67,9 @@ var ( //websocket连接存储 mapConnPool = sync.Map{} //每个websocket连接入口缓冲队列长度默认值 - websocketInChanLen = 50 + websocketInChanLen = 500 //每个websocket连接出口缓冲队列长度默认值 - websocketOutChanLen = 50 + websocketOutChanLen = 500 //是否开启debug openDebug = true //允许跨域的origin @@ -192,8 +192,7 @@ func (l *DataTransferLogic) setConnPool(conn *websocket.Conn, userInfo *auth.Use userId: userInfo.UserId, guestId: userInfo.GuestId, extendRenderProperty: extendRenderProperty{ - renderChan: make(chan []byte, renderChanLen), - renderConsumeTickTime: 1, //默认1纳秒,后面需要根据不同用户不同触发速度 + renderChan: make(chan []byte, renderChanLen), }, } //保存连接 diff --git a/server/websocket/internal/logic/ws_render_image.go b/server/websocket/internal/logic/ws_render_image.go index 7dcb0863..3d9ad20a 100644 --- a/server/websocket/internal/logic/ws_render_image.go +++ b/server/websocket/internal/logic/ws_render_image.go @@ -21,7 +21,7 @@ import ( var ( //每个websocket渲染任务缓冲队列长度默认值 - renderChanLen = 20 + renderChanLen = 200 ) // 渲染处理器 @@ -30,8 +30,7 @@ type renderProcessor struct { // 云渲染属性 type extendRenderProperty struct { - renderChan chan []byte //渲染消息入口的缓冲队列 - renderConsumeTickTime time.Duration //消费渲染消息时钟间隔(纳秒),用于后期控制不同类型用户渲染速度限制 + renderChan chan []byte //渲染消息入口的缓冲队列 } // 处理分发到这里的数据 @@ -52,18 +51,13 @@ func (w *wsConnectItem) consumeRenderImageData() { logx.Error("func renderImage err:", err) } }() - var duration time.Duration = 1 - if w.extendRenderProperty.renderConsumeTickTime > 0 { - duration = w.extendRenderProperty.renderConsumeTickTime - } - ticker := time.NewTicker(duration) - defer ticker.Stop() + var data []byte for { select { case <-w.closeChan: //已关闭 return - case <-ticker.C: //消费数据 - w.renderImage(<-w.extendRenderProperty.renderChan) + case data = <-w.extendRenderProperty.renderChan: //消费数据 + w.renderImage(data) } } } diff --git a/server/websocket/internal/logic/ws_user_connect_pool.go b/server/websocket/internal/logic/ws_user_connect_pool.go index 265e6490..8f02bb1d 100644 --- a/server/websocket/internal/logic/ws_user_connect_pool.go +++ b/server/websocket/internal/logic/ws_user_connect_pool.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "github.com/zeromicro/go-zero/core/logx" - "time" ) var ( @@ -30,8 +29,6 @@ func createUserConnPoolElement(userId, guestId int64, uniqueId string) { select { case userConnPoolCtlChan <- data: return - case <-time.After(time.Millisecond * 200): - return } } @@ -51,8 +48,6 @@ func deleteUserConnPoolElement(userId, guestId int64, uniqueId string) { select { case userConnPoolCtlChan <- data: return - case <-time.After(time.Millisecond * 200): - return } } @@ -68,8 +63,6 @@ func sendToOutChanByUserIndex(userId, guestId int64, message []byte) { select { case userConnPoolCtlChan <- data: return - case <-time.After(time.Millisecond * 200): - return } }