Commit 339584ee by wang

修复bug,天限制通过后不应该计数+1

parent d3e924d5
Showing with 13 additions and 9 deletions
......@@ -60,6 +60,7 @@ func whiteIp() {
"127.0.0.2",
"192.168.2.72",
"::1",
"192.168.2.241",
}
fmt.Println("白名单配置:"+redisKey)
......@@ -83,19 +84,22 @@ func businessList() {
func businessInterfaceList() {
redisKey:=openBusinessInterface
config:=map[string]interface{}{
//获取sku列表(获取价格相关字段) 5,10000000
//获取sku列表(根据class_id查询) 500,10000000
//获取sku列表(full-显示所有字段) 50,10000000
jdToken+"_"+GetSkuListByClass: map[string]interface{}{
"dayMaxNum":10000000,
"dayMaxNum":11,
"minMaxNum":5,
"totalMaxNum":10000,
},
jdToken+"_"+GetSkuListFull: map[string]interface{}{
"dayMaxNum":10000000,
"dayMaxNum":11,
"minMaxNum":5,
"totalMaxNum":10000,
},
jdToken+"_"+GetSkuListPrice: map[string]interface{}{
"dayMaxNum":10000000,
"minMaxNum":50,
"dayMaxNum":11,
"minMaxNum":5,
"totalMaxNum":10000,
},
/*baiduToken+"_"+getSkuListByClass: map[string]interface{}{
......@@ -114,8 +118,8 @@ func redisHashSet(key string,values map[string]interface{}) {
b,_=json.Marshal(string(b))
hsetStr:="Hset "+key+" "+string(hashk)+" "+string(b)
fmt.Println(hsetStr)
//fmt.Println("对应计时的min key\nflowUse_"+hashk+"_min")
//fmt.Println("对应计时的day key\nflowUse_"+hashk+"_day")
fmt.Println("对应计时的min key\nflowUse_"+hashk+"_min")
fmt.Println("对应计时的day key\nflowUse_"+hashk+"_day")
}
}
......
......@@ -86,10 +86,7 @@ func (this *openValidate) requestsNumValidate(token string,interfaceName string)
if(num>=int(interfaceConfig.dayMaxNum)){
common.PrintStdout().Printf("一天最大流量为: %d > %d",int(interfaceConfig.dayMaxNum),num)
return e.NewApiError("触发天级流控",FLOWERR4)
}else{
flow.incr()//验证成功,自增1
}
//一分钟最大流量验证
flow.SetFlowKey(INCRTYPEMIN)
num,err=flow.GetNum()//获取分钟使用流量
......@@ -101,6 +98,9 @@ func (this *openValidate) requestsNumValidate(token string,interfaceName string)
return e.NewApiError("触发分钟级流控",FLOWERR3)
}else{
flow.incr()//验证成功,自增1
flow.SetFlowKey(INCRTYPEDAY)
flow.incr()//同时天也自增1
}
return nil
}
......
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