Merge branch 'develop' of https://gitee.com/fusenpack/fusenapi into develop
This commit is contained in:
commit
e811bf3e4a
|
@ -67,9 +67,9 @@ var (
|
|||
//websocket连接存储
|
||||
mapConnPool = sync.Map{}
|
||||
//每个websocket连接入口缓冲队列长度默认值
|
||||
websocketInChanLen = 1000
|
||||
websocketInChanLen = 2000
|
||||
//每个websocket连接出口缓冲队列长度默认值
|
||||
websocketOutChanLen = 1000
|
||||
websocketOutChanLen = 2000
|
||||
//是否开启debug
|
||||
openDebug = true
|
||||
//允许跨域的origin
|
||||
|
|
|
@ -23,7 +23,7 @@ var (
|
|||
//每个websocket渲染任务缓冲队列长度默认值
|
||||
renderChanLen = 500
|
||||
//每个websocket渲染并发数
|
||||
renderChanConcurrency = 3
|
||||
renderChanConcurrency = 1
|
||||
)
|
||||
|
||||
// 渲染处理器
|
||||
|
@ -33,13 +33,11 @@ type renderProcessor struct {
|
|||
// 云渲染属性
|
||||
type extendRenderProperty struct {
|
||||
renderChan chan websocket_data.RenderImageReqMsg //渲染消息入口的缓冲队列
|
||||
selectColorIndex int //颜色选中索引
|
||||
templateTag string //模板标签
|
||||
}
|
||||
|
||||
// 处理分发到这里的数据
|
||||
func (r *renderProcessor) allocationMessage(w *wsConnectItem, data []byte) {
|
||||
//logx.Info("开始处理渲染任务消息:", string(data))
|
||||
logx.Info("收到渲染任务消息")
|
||||
var renderImageData websocket_data.RenderImageReqMsg
|
||||
if err := json.Unmarshal(data, &renderImageData); err != nil {
|
||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "数据格式错误", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0)
|
||||
|
@ -50,8 +48,9 @@ func (r *renderProcessor) allocationMessage(w *wsConnectItem, data []byte) {
|
|||
case <-w.closeChan: //已经关闭
|
||||
return
|
||||
case w.extendRenderProperty.renderChan <- renderImageData: //发入到缓冲队列
|
||||
w.extendRenderProperty.templateTag = renderImageData.RenderData.TemplateTag
|
||||
w.extendRenderProperty.selectColorIndex = renderImageData.RenderData.TemplateTagColor.SelectedColorIndex
|
||||
return
|
||||
case <- time.After(time.Millisecond * 50)://超过50毫秒丢弃
|
||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "渲染队列溢出,请稍后再发", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -60,7 +59,7 @@ func (r *renderProcessor) allocationMessage(w *wsConnectItem, data []byte) {
|
|||
func (w *wsConnectItem) consumeRenderImageData() {
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
logx.Error("func consumeRenderImageData err:", err)
|
||||
logx.Error("func consumeRenderImageData panic:", err)
|
||||
}
|
||||
}()
|
||||
//限制并发
|
||||
|
@ -71,19 +70,11 @@ func (w *wsConnectItem) consumeRenderImageData() {
|
|||
case <-w.closeChan: //已关闭
|
||||
return
|
||||
case data := <-w.extendRenderProperty.renderChan: //消费数据
|
||||
if data.RenderData.TemplateTag != w.extendRenderProperty.templateTag{
|
||||
logx.Info("由于模板切换了,丢弃该渲染消息")
|
||||
continue
|
||||
}
|
||||
if data.RenderData.TemplateTagColor.SelectedColorIndex != w.extendRenderProperty.selectColorIndex{
|
||||
logx.Info("由于模板切换了颜色,丢弃该渲染消息")
|
||||
continue
|
||||
}
|
||||
limitChan <- struct{}{}
|
||||
go func(d websocket_data.RenderImageReqMsg) {
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
logx.Error("func renderImage err:", err)
|
||||
logx.Error("func renderImage panic:", err)
|
||||
}
|
||||
}()
|
||||
defer func() {
|
||||
|
|
|
@ -318,7 +318,7 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq
|
|||
err = curl.NewClient(ctx, &curl.Config{
|
||||
BaseUrl: *l.BLMServiceUrl,
|
||||
Url: constants.BLMServiceUrlLogoCombine,
|
||||
RequireTimeout: time.Second * 30,
|
||||
RequireTimeout: time.Second * 15,
|
||||
}).PostJson(postMap, &resultBLM)
|
||||
|
||||
logc.Infof(ctx, "合图--算法请求--合图--结束时间:%v", time.Now().UTC())
|
||||
|
|
Loading…
Reference in New Issue
Block a user