This commit is contained in:
邹宗楠
2022-10-22 22:45:36 +08:00
parent c862340c56
commit 2ed93fe209
66 changed files with 10 additions and 156 deletions

View File

@@ -5,6 +5,7 @@ import (
"compress/gzip"
"errors"
"fmt"
"git.rosy.net.cn/jx-callback/globals"
"io/ioutil"
"math"
"net"
@@ -117,18 +118,15 @@ func AccessPlatformAPIWithRetry(client *http.Client, handleRequest func() *http.
request.Header.Del(KeyTrackInfo)
}
trackInfo += ", " + utils.GetUUID()
baseapi.SugarLogger.Debugf("begin AccessPlatformAPIWithRetry:%s do:%s url:%v, request:%s", trackInfo, request.Method, request.URL, getClonedData(request.URL, savedBuf))
response, err := client.Do(request)
usedMilliSecond := time.Now().Sub(beginTime) / time.Millisecond
baseapi.SugarLogger.Debugf("end AccessPlatformAPIWithRetry:%s do:%s url:%v, usedMilliSecond:%d", trackInfo, request.Method, request.URL, usedMilliSecond)
if err != nil {
baseapi.SugarLogger.Debugf("AccessPlatformAPIWithRetry:%s client.Get return err:%v", trackInfo, err)
err, ok := err.(net.Error)
globals.SugarLogger.Debugf("AccessPlatformAPIWithRetry err %s", err)
recoverableErrorRetryCount++
if ok /*&& err.Timeout()*/ && recoverableErrorRetryCount <= config.MaxRecoverableRetryCount { // 只要是网络错误都重试
continue
} else {
baseapi.SugarLogger.Errorf("AccessPlatformAPIWithRetry:%s access api url:%v, error:%v", trackInfo, request.URL, err)
return ErrAPIAccessFailed
}
}