Commit 72849c98 by 杨树贤

加入判断逻辑

parent 01f4579f
......@@ -162,6 +162,7 @@ func CommonController(ctx *gin.Context) map[string]interface{} {
case <-timeout:
logger.Log("协程整体处理超时", "sku", 1)
panic("协程整体处理超时")
return temp // 超时,返回已经收到的部分数据
}
}
......
......@@ -10,6 +10,7 @@ import (
"sort"
"strconv"
"sync"
"time"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
......@@ -59,6 +60,12 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
//是否展示spu额外信息
showSpuExtra := ctx.Request.FormValue("show_spu_extra")
//是否超时
timeout := ctx.Request.FormValue("timeout")
if timeout == "1" {
time.Sleep(time.Second * 15)
}
//批量获取商品详情
skuArr := gredis.Hmget("default_r", "sku", goodsIds)
//为了性能着想,这边也先去批量获取spu的信息
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment