From 7abebc215c968f93ba348c4c60c401962bc1db0f Mon Sep 17 00:00:00 2001 From: gazebo Date: Sat, 22 Jun 2019 18:04:14 +0800 Subject: [PATCH] =?UTF-8?q?-=20DefClientTimeout=E8=B0=83=E6=95=B4=E4=B8=BA?= =?UTF-8?q?5=E7=A7=92=20-=20DefMaxRecoverableRetryCount=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E4=B8=BA1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platformapi/platformapi.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/platformapi/platformapi.go b/platformapi/platformapi.go index 9eb04ed4..505c667f 100644 --- a/platformapi/platformapi.go +++ b/platformapi/platformapi.go @@ -17,10 +17,9 @@ import ( ) const ( - DefClientTimeout = 10 * time.Second + DefClientTimeout = 5 * time.Second DefSleepSecondWhenExceedLimit = 3 * time.Second - DefRandSlice = 10 - DefMaxRecoverableRetryCount = 3 + DefMaxRecoverableRetryCount = 1 DefMaxExceedLimitRetryCount = 25 ) @@ -106,8 +105,8 @@ func AccessPlatformAPIWithRetry(client *http.Client, handleRequest func() *http. if err != nil { baseapi.SugarLogger.Debugf("AccessPlatformAPIWithRetry:%s client.Get return err:%v", trackID, err) err, ok := err.(net.Error) + recoverableErrorRetryCount++ if ok /*&& err.Timeout()*/ && recoverableErrorRetryCount <= config.MaxRecoverableRetryCount { // 只要是网络错误都重试 - recoverableErrorRetryCount++ continue } else { baseapi.SugarLogger.Errorf("AccessPlatformAPIWithRetry:%s access api url:%v, request:%v, error:%v", trackID, request.URL, getClonedData(request.URL, savedBuf), err)