- 处理美团外卖错误“711 接口调用过于频繁,触发流控,请降低调用频率”
This commit is contained in:
@@ -40,7 +40,8 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ErrCodeNoAppFood = 805
|
ErrCodeAccessLimited = 711 // 接口调用过于频繁,触发流控,请降低调用频率
|
||||||
|
ErrCodeNoAppFood = 805 // 不存在此菜品
|
||||||
)
|
)
|
||||||
|
|
||||||
type API struct {
|
type API struct {
|
||||||
@@ -138,10 +139,13 @@ func (a *API) AccessAPI2(cmd string, isGet bool, bizParams map[string]interface{
|
|||||||
},
|
},
|
||||||
a.config,
|
a.config,
|
||||||
func(jsonResult1 map[string]interface{}) (errLevel string, err error) {
|
func(jsonResult1 map[string]interface{}) (errLevel string, err error) {
|
||||||
if _, ok := jsonResult1["error"]; ok {
|
if errObj, ok := jsonResult1["error"]; ok {
|
||||||
baseapi.SugarLogger.Debugf("mtwm AccessAPI failed, jsonResult1:%s", utils.Format4Output(jsonResult1, true))
|
baseapi.SugarLogger.Debugf("mtwm AccessAPI failed, jsonResult1:%s", utils.Format4Output(jsonResult1, true))
|
||||||
errorInfo := jsonResult1["error"].(map[string]interface{})
|
errorInfo := errObj.(map[string]interface{})
|
||||||
newErr := utils.NewErrorIntCode(errorInfo["msg"].(string), int(utils.MustInterface2Int64(errorInfo["code"])))
|
newErr := utils.NewErrorIntCode(errorInfo["msg"].(string), int(utils.MustInterface2Int64(errorInfo["code"])))
|
||||||
|
if newErr.IntCode() == ErrCodeAccessLimited {
|
||||||
|
return platformapi.ErrLevelExceedLimit, newErr
|
||||||
|
}
|
||||||
return platformapi.ErrLevelCodeIsNotOK, newErr
|
return platformapi.ErrLevelCodeIsNotOK, newErr
|
||||||
}
|
}
|
||||||
retVal = jsonResult1[resultKey]
|
retVal = jsonResult1[resultKey]
|
||||||
|
|||||||
Reference in New Issue
Block a user