Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
wang
/
golang-open-platform
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
339584ee
authored
Feb 04, 2021
by
wang
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
修复bug,天限制通过后不应该计数+1
parent
d3e924d5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
9 deletions
doc/redis_config_generate.go
open/validate.go
doc/redis_config_generate.go
View file @
339584ee
...
@@ -60,6 +60,7 @@ func whiteIp() {
...
@@ -60,6 +60,7 @@ func whiteIp() {
"127.0.0.2"
,
"127.0.0.2"
,
"192.168.2.72"
,
"192.168.2.72"
,
"::1"
,
"::1"
,
"192.168.2.241"
,
}
}
fmt
.
Println
(
"白名单配置:"
+
redisKey
)
fmt
.
Println
(
"白名单配置:"
+
redisKey
)
...
@@ -83,19 +84,22 @@ func businessList() {
...
@@ -83,19 +84,22 @@ func businessList() {
func
businessInterfaceList
()
{
func
businessInterfaceList
()
{
redisKey
:=
openBusinessInterface
redisKey
:=
openBusinessInterface
config
:=
map
[
string
]
interface
{}{
config
:=
map
[
string
]
interface
{}{
//获取sku列表(获取价格相关字段) 5,10000000
//获取sku列表(根据class_id查询) 500,10000000
//获取sku列表(full-显示所有字段) 50,10000000
jdToken
+
"_"
+
GetSkuListByClass
:
map
[
string
]
interface
{}{
jdToken
+
"_"
+
GetSkuListByClass
:
map
[
string
]
interface
{}{
"dayMaxNum"
:
1
0000000
,
"dayMaxNum"
:
1
1
,
"minMaxNum"
:
5
,
"minMaxNum"
:
5
,
"totalMaxNum"
:
10000
,
"totalMaxNum"
:
10000
,
},
},
jdToken
+
"_"
+
GetSkuListFull
:
map
[
string
]
interface
{}{
jdToken
+
"_"
+
GetSkuListFull
:
map
[
string
]
interface
{}{
"dayMaxNum"
:
1
0000000
,
"dayMaxNum"
:
1
1
,
"minMaxNum"
:
5
,
"minMaxNum"
:
5
,
"totalMaxNum"
:
10000
,
"totalMaxNum"
:
10000
,
},
},
jdToken
+
"_"
+
GetSkuListPrice
:
map
[
string
]
interface
{}{
jdToken
+
"_"
+
GetSkuListPrice
:
map
[
string
]
interface
{}{
"dayMaxNum"
:
1
0000000
,
"dayMaxNum"
:
1
1
,
"minMaxNum"
:
5
0
,
"minMaxNum"
:
5
,
"totalMaxNum"
:
10000
,
"totalMaxNum"
:
10000
,
},
},
/*baiduToken+"_"+getSkuListByClass: map[string]interface{}{
/*baiduToken+"_"+getSkuListByClass: map[string]interface{}{
...
@@ -114,8 +118,8 @@ func redisHashSet(key string,values map[string]interface{}) {
...
@@ -114,8 +118,8 @@ func redisHashSet(key string,values map[string]interface{}) {
b
,
_
=
json
.
Marshal
(
string
(
b
))
b
,
_
=
json
.
Marshal
(
string
(
b
))
hsetStr
:=
"Hset "
+
key
+
" "
+
string
(
hashk
)
+
" "
+
string
(
b
)
hsetStr
:=
"Hset "
+
key
+
" "
+
string
(
hashk
)
+
" "
+
string
(
b
)
fmt
.
Println
(
hsetStr
)
fmt
.
Println
(
hsetStr
)
//
fmt.Println("对应计时的min key\nflowUse_"+hashk+"_min")
fmt
.
Println
(
"对应计时的min key
\n
flowUse_"
+
hashk
+
"_min"
)
//
fmt.Println("对应计时的day key\nflowUse_"+hashk+"_day")
fmt
.
Println
(
"对应计时的day key
\n
flowUse_"
+
hashk
+
"_day"
)
}
}
}
}
...
...
open/validate.go
View file @
339584ee
...
@@ -86,10 +86,7 @@ func (this *openValidate) requestsNumValidate(token string,interfaceName string)
...
@@ -86,10 +86,7 @@ func (this *openValidate) requestsNumValidate(token string,interfaceName string)
if
(
num
>=
int
(
interfaceConfig
.
dayMaxNum
)){
if
(
num
>=
int
(
interfaceConfig
.
dayMaxNum
)){
common
.
PrintStdout
()
.
Printf
(
"一天最大流量为: %d > %d"
,
int
(
interfaceConfig
.
dayMaxNum
),
num
)
common
.
PrintStdout
()
.
Printf
(
"一天最大流量为: %d > %d"
,
int
(
interfaceConfig
.
dayMaxNum
),
num
)
return
e
.
NewApiError
(
"触发天级流控"
,
FLOWERR4
)
return
e
.
NewApiError
(
"触发天级流控"
,
FLOWERR4
)
}
else
{
flow
.
incr
()
//验证成功,自增1
}
}
//一分钟最大流量验证
//一分钟最大流量验证
flow
.
SetFlowKey
(
INCRTYPEMIN
)
flow
.
SetFlowKey
(
INCRTYPEMIN
)
num
,
err
=
flow
.
GetNum
()
//获取分钟使用流量
num
,
err
=
flow
.
GetNum
()
//获取分钟使用流量
...
@@ -101,6 +98,9 @@ func (this *openValidate) requestsNumValidate(token string,interfaceName string)
...
@@ -101,6 +98,9 @@ func (this *openValidate) requestsNumValidate(token string,interfaceName string)
return
e
.
NewApiError
(
"触发分钟级流控"
,
FLOWERR3
)
return
e
.
NewApiError
(
"触发分钟级流控"
,
FLOWERR3
)
}
else
{
}
else
{
flow
.
incr
()
//验证成功,自增1
flow
.
incr
()
//验证成功,自增1
flow
.
SetFlowKey
(
INCRTYPEDAY
)
flow
.
incr
()
//同时天也自增1
}
}
return
nil
return
nil
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment