- use millisecond for limit access speed
This commit is contained in:
@@ -2,28 +2,40 @@ package ebaiapi
|
||||
|
||||
import "git.rosy.net.cn/baseapi/platformapi"
|
||||
|
||||
const (
|
||||
allAPI = "all"
|
||||
)
|
||||
|
||||
var (
|
||||
apiLimitConfigs = map[string]*platformapi.LimiterConfig{
|
||||
allAPI: &platformapi.LimiterConfig{
|
||||
MaxAccessCount: 5,
|
||||
TimeGapMilliSecond: 1000,
|
||||
},
|
||||
"sku.create": &platformapi.LimiterConfig{
|
||||
MaxAccessCount: 5 - 1,
|
||||
TimeGapInSecond: 1,
|
||||
MaxAccessCount: 5 - 1,
|
||||
TimeGapMilliSecond: 1000,
|
||||
},
|
||||
"sku.delete": &platformapi.LimiterConfig{
|
||||
MaxAccessCount: 1,
|
||||
TimeGapInSecond: 1,
|
||||
MaxAccessCount: 1,
|
||||
TimeGapMilliSecond: 2000,
|
||||
},
|
||||
"sku.shop.category.delete": &platformapi.LimiterConfig{
|
||||
MaxAccessCount: 5 - 2,
|
||||
TimeGapInSecond: 1,
|
||||
MaxAccessCount: 1,
|
||||
TimeGapMilliSecond: 1000,
|
||||
},
|
||||
"sku.shop.category.create": &platformapi.LimiterConfig{
|
||||
MaxAccessCount: 5 - 1,
|
||||
TimeGapInSecond: 1,
|
||||
MaxAccessCount: 2,
|
||||
TimeGapMilliSecond: 1000,
|
||||
},
|
||||
"sku.list": &platformapi.LimiterConfig{
|
||||
MaxAccessCount: 5 - 3,
|
||||
TimeGapMilliSecond: 1000,
|
||||
},
|
||||
}
|
||||
|
||||
defaultAPILimitConfig = &platformapi.LimiterConfig{
|
||||
MaxAccessCount: 5 - 2,
|
||||
TimeGapInSecond: 1,
|
||||
MaxAccessCount: 5 - 2,
|
||||
TimeGapMilliSecond: 1000,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -72,6 +72,7 @@ func (a *API) signParams(params url.Values) string {
|
||||
}
|
||||
|
||||
func (a *API) AccessAPI(cmd string, body map[string]interface{}) (retVal *ResponseResult, err error) {
|
||||
// a.speedLimiter.AccessAPI(allAPI)
|
||||
a.speedLimiter.AccessAPI(cmd)
|
||||
if body == nil {
|
||||
body = make(map[string]interface{}, 0)
|
||||
|
||||
Reference in New Issue
Block a user