|
|
@@ -62,7 +62,7 @@ public class SpiderApiService {
|
|
|
* @param delayMs 重试延迟(毫秒)
|
|
|
* @return 业务数据(T)
|
|
|
*/
|
|
|
- private <T> T executeWithRetry(Callable<ResultWrapper<T>> callable, int maxRetries, long delayMs) {
|
|
|
+ private <T> T executeWithRetry(Callable<ResultWrapper<T>> callable, String methodName, int maxRetries, long delayMs) {
|
|
|
int retryCount = 0;
|
|
|
while (retryCount < maxRetries) {
|
|
|
try {
|
|
|
@@ -70,10 +70,10 @@ public class SpiderApiService {
|
|
|
if (result.getCode() == 0) { // 状态码为0表示成功,直接返回数据
|
|
|
return result.getData();
|
|
|
} else {
|
|
|
- log.warn("业务执行失败,状态码:{},重试次数:{}", result.getCode(), retryCount + 1);
|
|
|
+ log.error("业务执行失败,方法:{},状态码:{},重试次数:{}", methodName, result.getCode(), retryCount + 1);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
- log.error("执行异常,重试次数:{},异常信息:{}", retryCount + 1, e.getMessage(), e);
|
|
|
+ log.error("执行异常,方法:{},重试次数:{},异常信息:{}", methodName, retryCount + 1, e.getMessage(), e);
|
|
|
}
|
|
|
|
|
|
retryCount++;
|
|
|
@@ -87,7 +87,7 @@ public class SpiderApiService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- log.error("达到最大重试次数({}次),执行失败", maxRetries);
|
|
|
+ log.error("达到最大重试次数({}次),方法:{},执行失败", maxRetries, methodName);
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
@@ -165,7 +165,7 @@ public class SpiderApiService {
|
|
|
log.error("搜索内容详情请求异常", e);
|
|
|
throw e; // 抛出异常,由通用重试方法捕获并重试
|
|
|
}
|
|
|
- }, maxRetries, delayMs); // 使用类级别的重试参数(统一配置)
|
|
|
+ }, "searchContentDetail", maxRetries, delayMs); // 使用类级别的重试参数(统一配置)
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -219,7 +219,7 @@ public class SpiderApiService {
|
|
|
log.error("搜索内容图片请求异常", e);
|
|
|
throw e; // 抛出异常,由通用重试方法捕获并重试
|
|
|
}
|
|
|
- }, maxRetries, delayMs); // 重试参数:3次重试,2秒延迟
|
|
|
+ }, "searchContentImage", maxRetries, delayMs); // 重试参数:3次重试,2秒延迟
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -281,7 +281,7 @@ public class SpiderApiService {
|
|
|
log.error("搜索内容视频请求异常", e);
|
|
|
throw e;
|
|
|
}
|
|
|
- }, maxRetries, delayMs);
|
|
|
+ }, "searchContentVideoDetail", maxRetries, delayMs);
|
|
|
}
|
|
|
|
|
|
public SpiderHKVideoDetailItem searchContentVideoDetail(String videoId) {
|
|
|
@@ -322,6 +322,6 @@ public class SpiderApiService {
|
|
|
log.error("搜索内容视频详情请求异常", e);
|
|
|
throw e; // 抛出异常,由通用重试方法捕获并重试
|
|
|
}
|
|
|
- }, maxRetries, delayMs); // 使用类级别的重试参数(maxRetries=3,delayMs=1000ms)
|
|
|
+ }, "searchContentVideoDetail", maxRetries, delayMs); // 使用类级别的重试参数(maxRetries=3,delayMs=1000ms)
|
|
|
}
|
|
|
}
|