feat(3.3.0) 客户端基于netty 改造和修改作者名字为opensnail
This commit is contained in:
parent
ce8d2c550d
commit
9c133fd278
@ -87,7 +87,7 @@ We use [Gitee Issues](https://gitee.com/aizuda/easy-retry/issues) and [Pull Requ
|
||||
```
|
||||
/**
|
||||
* 这是你对这个类的描述,如比较长,多行也行
|
||||
* @author www.byteblogs.com
|
||||
* @author opensnail
|
||||
* @since 1.5.1
|
||||
*/
|
||||
public class YourClass{
|
||||
|
@ -12,7 +12,7 @@ import java.util.Map;
|
||||
/**
|
||||
* Easy Retry 客户端注册器
|
||||
*
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2022-03-04 18:44
|
||||
*/
|
||||
public class EasyRetryClientsRegistrar implements ImportBeanDefinitionRegistrar, EnvironmentAware {
|
||||
|
@ -9,7 +9,7 @@ import java.lang.annotation.*;
|
||||
/**
|
||||
* 在启动类上添加EnableEasyRetry注解开启Easy Retry功能
|
||||
*
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2021-12-31 18:45
|
||||
*/
|
||||
@Target({ElementType.TYPE})
|
||||
|
@ -3,7 +3,7 @@ package com.aizuda.easy.retry.client.common;
|
||||
/**
|
||||
* 组件生命周期
|
||||
*
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2021-11-19 14:43
|
||||
*/
|
||||
public interface Lifecycle {
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.aizuda.easy.retry.client.common;
|
||||
|
||||
import com.aizuda.easy.retry.client.common.annotation.Mapping;
|
||||
import com.aizuda.easy.retry.client.common.netty.RequestMethod;
|
||||
import com.aizuda.easy.retry.client.common.rpc.client.RequestMethod;
|
||||
import com.aizuda.easy.retry.common.core.constant.SystemConstants.HTTP_PATH;
|
||||
import com.aizuda.easy.retry.common.core.model.Result;
|
||||
|
||||
@ -9,7 +9,7 @@ import com.aizuda.easy.retry.common.core.model.Result;
|
||||
/**
|
||||
* netty 客户端请求类
|
||||
*
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2023-05-11 21:28
|
||||
* @since 1.3.0
|
||||
*/
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.aizuda.easy.retry.client.common;
|
||||
|
||||
import com.aizuda.easy.retry.client.common.netty.server.EndPointInfo;
|
||||
import com.aizuda.easy.retry.client.common.rpc.supports.scan.EndPointInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.aizuda.easy.retry.client.common.annotation;
|
||||
|
||||
import com.aizuda.easy.retry.client.common.netty.RequestMethod;
|
||||
import com.aizuda.easy.retry.client.common.rpc.client.RequestMethod;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
@ -11,7 +11,7 @@ import java.lang.annotation.Target;
|
||||
/**
|
||||
* 接口定义
|
||||
*
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2023-05-11 22:32
|
||||
* @since 1.3.0
|
||||
*/
|
||||
@ -23,7 +23,7 @@ public @interface Mapping {
|
||||
/**
|
||||
* 请求类型
|
||||
*/
|
||||
RequestMethod method() default RequestMethod.GET;
|
||||
RequestMethod method() default RequestMethod.POST;
|
||||
|
||||
/**
|
||||
* 请求路径
|
||||
|
@ -2,7 +2,7 @@ package com.aizuda.easy.retry.client.common.appender;
|
||||
|
||||
import com.aizuda.easy.retry.client.common.log.report.LogReportFactory;
|
||||
import com.aizuda.easy.retry.client.common.log.support.EasyRetryLogManager;
|
||||
import com.aizuda.easy.retry.client.common.netty.NettyChannel;
|
||||
import com.aizuda.easy.retry.client.common.rpc.client.NettyChannel;
|
||||
import com.aizuda.easy.retry.common.log.dto.LogContentDTO;
|
||||
import com.aizuda.easy.retry.common.log.constant.LogFieldConstants;
|
||||
import org.apache.log4j.MDC;
|
||||
|
@ -2,7 +2,7 @@ package com.aizuda.easy.retry.client.common.appender;
|
||||
|
||||
import com.aizuda.easy.retry.client.common.log.report.LogReportFactory;
|
||||
import com.aizuda.easy.retry.client.common.log.support.EasyRetryLogManager;
|
||||
import com.aizuda.easy.retry.client.common.netty.NettyChannel;
|
||||
import com.aizuda.easy.retry.client.common.rpc.client.NettyChannel;
|
||||
import com.aizuda.easy.retry.common.log.dto.LogContentDTO;
|
||||
import com.aizuda.easy.retry.common.log.constant.LogFieldConstants;
|
||||
import org.apache.log4j.AppenderSkeleton;
|
||||
|
@ -8,7 +8,7 @@ import ch.qos.logback.core.CoreConstants;
|
||||
import ch.qos.logback.core.UnsynchronizedAppenderBase;
|
||||
import com.aizuda.easy.retry.client.common.log.report.LogReportFactory;
|
||||
import com.aizuda.easy.retry.client.common.log.support.EasyRetryLogManager;
|
||||
import com.aizuda.easy.retry.client.common.netty.NettyChannel;
|
||||
import com.aizuda.easy.retry.client.common.rpc.client.NettyChannel;
|
||||
import com.aizuda.easy.retry.common.log.dto.LogContentDTO;
|
||||
import com.aizuda.easy.retry.common.log.constant.LogFieldConstants;
|
||||
import org.slf4j.MDC;
|
||||
|
@ -1,7 +1,8 @@
|
||||
package com.aizuda.easy.retry.client.common.netty.server;
|
||||
package com.aizuda.easy.retry.client.common.cache;
|
||||
|
||||
import cn.hutool.core.lang.Pair;
|
||||
import com.aizuda.easy.retry.client.common.netty.RequestMethod;
|
||||
import com.aizuda.easy.retry.client.common.rpc.client.RequestMethod;
|
||||
import com.aizuda.easy.retry.client.common.rpc.supports.scan.EndPointInfo;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
@ -2,12 +2,11 @@ package com.aizuda.easy.retry.client.common.cache;
|
||||
|
||||
import com.aizuda.easy.retry.client.common.Lifecycle;
|
||||
import com.aizuda.easy.retry.client.common.NettyClient;
|
||||
import com.aizuda.easy.retry.client.common.proxy.RequestBuilder;
|
||||
import com.aizuda.easy.retry.client.common.rpc.client.RequestBuilder;
|
||||
import com.aizuda.easy.retry.common.core.constant.SystemConstants;
|
||||
import com.aizuda.easy.retry.common.log.EasyRetryLog;
|
||||
import com.aizuda.easy.retry.common.core.model.NettyResult;
|
||||
import com.aizuda.easy.retry.common.core.util.JsonUtil;
|
||||
import com.aizuda.easy.retry.common.log.EasyRetryLog;
|
||||
import com.aizuda.easy.retry.server.model.dto.ConfigDTO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.core.annotation.Order;
|
||||
@ -20,7 +19,7 @@ import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2022-05-02 21:06
|
||||
*/
|
||||
@Component
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.aizuda.easy.retry.client.common.client;
|
||||
|
||||
import com.aizuda.easy.retry.client.common.annotation.Mapping;
|
||||
import com.aizuda.easy.retry.client.common.netty.RequestMethod;
|
||||
import com.aizuda.easy.retry.client.common.rpc.client.RequestMethod;
|
||||
import com.aizuda.easy.retry.common.core.constant.SystemConstants.HTTP_PATH;
|
||||
import com.aizuda.easy.retry.common.core.model.NettyResult;
|
||||
import com.aizuda.easy.retry.server.model.dto.LogTaskDTO;
|
||||
@ -13,15 +13,12 @@ import java.util.List;
|
||||
/**
|
||||
* netty 客户端请求类
|
||||
*
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2023-05-11 21:28
|
||||
* @since 1.3.0
|
||||
*/
|
||||
public interface NettyClient {
|
||||
|
||||
// @Mapping(method = RequestMethod.GET, path = HTTP_PATH.CONFIG)
|
||||
// Result getConfig(Integer version);
|
||||
|
||||
@Mapping(method = RequestMethod.POST, path = HTTP_PATH.BATCH_REPORT)
|
||||
NettyResult reportRetryInfo(List<RetryTaskDTO> list);
|
||||
|
||||
|
@ -13,7 +13,7 @@ import java.util.Objects;
|
||||
/**
|
||||
* easy retry 客户端配置
|
||||
*
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2022-03-04 15:53
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
@ -3,7 +3,7 @@ package com.aizuda.easy.retry.client.common.exception;
|
||||
import com.aizuda.easy.retry.common.core.exception.BaseEasyRetryException;
|
||||
|
||||
/**
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2022-03-03 14:49
|
||||
*/
|
||||
public class EasyRetryClientException extends BaseEasyRetryException {
|
||||
|
@ -3,7 +3,7 @@ package com.aizuda.easy.retry.client.common.exception;
|
||||
import com.aizuda.easy.retry.common.core.exception.BaseEasyRetryException;
|
||||
|
||||
/**
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2022-03-03 14:49
|
||||
*/
|
||||
public class EasyRetryClientTimeOutException extends BaseEasyRetryException {
|
||||
|
@ -18,7 +18,7 @@ import java.util.List;
|
||||
/**
|
||||
* 系统关闭监听器
|
||||
*
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2021-11-19 19:00
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
@ -19,7 +19,7 @@ import java.util.List;
|
||||
/**
|
||||
* 系统启动监听器
|
||||
*
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2021-11-19 19:00
|
||||
*/
|
||||
@Component
|
||||
|
@ -1,8 +1,8 @@
|
||||
package com.aizuda.easy.retry.client.common.intercepter;
|
||||
|
||||
import com.aizuda.easy.retry.client.common.netty.server.EndPointInfo;
|
||||
import com.aizuda.easy.retry.client.common.netty.server.HttpRequest;
|
||||
import com.aizuda.easy.retry.client.common.netty.server.HttpResponse;
|
||||
import com.aizuda.easy.retry.client.common.rpc.supports.scan.EndPointInfo;
|
||||
import com.aizuda.easy.retry.client.common.rpc.supports.http.HttpRequest;
|
||||
import com.aizuda.easy.retry.client.common.rpc.supports.http.HttpResponse;
|
||||
|
||||
/**
|
||||
* @author: opensnail
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.aizuda.easy.retry.client.common.log.report;
|
||||
|
||||
import com.aizuda.easy.retry.client.common.client.NettyClient;
|
||||
import com.aizuda.easy.retry.client.common.proxy.RequestBuilder;
|
||||
import com.aizuda.easy.retry.client.common.rpc.client.RequestBuilder;
|
||||
import com.aizuda.easy.retry.common.log.EasyRetryLog;
|
||||
import com.aizuda.easy.retry.common.core.model.NettyResult;
|
||||
import com.aizuda.easy.retry.common.core.window.Listener;
|
||||
@ -13,7 +13,7 @@ import java.util.List;
|
||||
/**
|
||||
* 批量异步上报
|
||||
*
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2022-03-08 13:54
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
@ -1,17 +0,0 @@
|
||||
package com.aizuda.easy.retry.client.common.netty;
|
||||
|
||||
import com.aizuda.easy.retry.client.common.netty.server.NettyHttpRequest;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author: opensnail
|
||||
* @date : 2024-04-12
|
||||
* @since : 3.3.0
|
||||
*/
|
||||
@Component
|
||||
public class DispatcherRequestHandler {
|
||||
|
||||
public void dispatch(NettyHttpRequest nettyHttpRequest) {
|
||||
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
package com.aizuda.easy.retry.client.common.netty.server;
|
||||
|
||||
/**
|
||||
* @author: opensnail
|
||||
* @date : 2024-04-12
|
||||
* @since : 3.3.0
|
||||
*/
|
||||
public class HttpRequest {
|
||||
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
package com.aizuda.easy.retry.client.common.netty.server;
|
||||
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.http.HttpHeaders;
|
||||
import io.netty.handler.codec.http.HttpMethod;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* netty客户端请求模型
|
||||
*
|
||||
* @author: www.byteblogs.com
|
||||
* @date : 2023-07-24 09:32
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
public class NettyHttpRequest {
|
||||
|
||||
private ChannelHandlerContext channelHandlerContext;
|
||||
|
||||
private String content;
|
||||
|
||||
private boolean keepAlive;
|
||||
|
||||
private HttpMethod method;
|
||||
|
||||
private String uri;
|
||||
|
||||
private HttpHeaders headers;
|
||||
|
||||
}
|
@ -1,186 +0,0 @@
|
||||
package com.aizuda.easy.retry.client.common.netty.server;
|
||||
|
||||
import cn.hutool.core.net.url.UrlBuilder;
|
||||
import cn.hutool.core.util.ServiceLoaderUtil;
|
||||
import com.aizuda.easy.retry.client.common.config.EasyRetryProperties;
|
||||
import com.aizuda.easy.retry.client.common.exception.EasyRetryClientException;
|
||||
import com.aizuda.easy.retry.client.common.intercepter.HandlerInterceptor;
|
||||
import com.aizuda.easy.retry.client.common.netty.RequestMethod;
|
||||
import com.aizuda.easy.retry.common.core.constant.SystemConstants;
|
||||
import com.aizuda.easy.retry.common.core.context.SpringContext;
|
||||
import com.aizuda.easy.retry.common.core.model.EasyRetryRequest;
|
||||
import com.aizuda.easy.retry.common.core.model.NettyResult;
|
||||
import com.aizuda.easy.retry.common.core.model.Result;
|
||||
import com.aizuda.easy.retry.common.core.util.JsonUtil;
|
||||
import com.aizuda.easy.retry.common.log.EasyRetryLog;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
import io.netty.handler.codec.http.*;
|
||||
import io.netty.util.CharsetUtil;
|
||||
import org.springframework.scheduling.concurrent.CustomizableThreadFactory;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author: opensnail
|
||||
* @date : 2024-04-11 16:03
|
||||
* @since : 3.3.0
|
||||
*/
|
||||
public class NettyHttpServerHandler extends SimpleChannelInboundHandler<FullHttpRequest> {
|
||||
|
||||
private static final ThreadPoolExecutor DISPATCHER_THREAD_POOL = new ThreadPoolExecutor(
|
||||
16, 16, 1L, TimeUnit.SECONDS, new LinkedBlockingQueue<>(),
|
||||
new CustomizableThreadFactory("snail-netty-server-"));
|
||||
|
||||
public NettyHttpServerHandler() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void channelRead0(ChannelHandlerContext channelHandlerContext, FullHttpRequest fullHttpRequest) {
|
||||
|
||||
String content = fullHttpRequest.content().toString(CharsetUtil.UTF_8);
|
||||
String uri = fullHttpRequest.uri();
|
||||
String name = fullHttpRequest.method().name();
|
||||
HttpHeaders headers = fullHttpRequest.headers();
|
||||
|
||||
NettyHttpRequest nettyHttpRequest = NettyHttpRequest.builder()
|
||||
.keepAlive(HttpUtil.isKeepAlive(fullHttpRequest))
|
||||
.uri(fullHttpRequest.uri())
|
||||
.channelHandlerContext(channelHandlerContext)
|
||||
.method(fullHttpRequest.method())
|
||||
.headers(fullHttpRequest.headers())
|
||||
.content(fullHttpRequest.content().toString(CharsetUtil.UTF_8))
|
||||
.build();
|
||||
|
||||
// 执行任务
|
||||
DISPATCHER_THREAD_POOL.execute(() -> {
|
||||
|
||||
List<HandlerInterceptor> handlerInterceptors = handlerInterceptors();
|
||||
EasyRetryRequest retryRequest = JsonUtil.parseObject(content, EasyRetryRequest.class);
|
||||
HttpRequest httpRequest = new HttpRequest();
|
||||
HttpResponse httpResponse = new HttpResponse();
|
||||
EndPointInfo endPointInfo = null;
|
||||
Result resultObj = null;
|
||||
Exception e;
|
||||
try {
|
||||
EasyRetryProperties properties = SpringContext.getBean(EasyRetryProperties.class);
|
||||
String easyRetryAuth = headers.getAsString(SystemConstants.EASY_RETRY_AUTH_TOKEN);
|
||||
String configToken = Optional.ofNullable(properties.getToken()).orElse(SystemConstants.DEFAULT_TOKEN);
|
||||
if (!configToken.equals(easyRetryAuth)) {
|
||||
throw new EasyRetryClientException("认证失败.【请检查配置的Token是否正确】");
|
||||
}
|
||||
|
||||
UrlBuilder builder = UrlBuilder.ofHttp(uri);
|
||||
RequestMethod requestMethod = RequestMethod.valueOf(name);
|
||||
|
||||
endPointInfo = EndPointInfoCache.get(builder.getPathStr(), requestMethod);
|
||||
Class<?>[] paramTypes = endPointInfo.getMethod().getParameterTypes();
|
||||
Object[] args = retryRequest.getArgs();
|
||||
|
||||
Object[] deSerialize = (Object[]) deSerialize(JsonUtil.toJsonString(args), endPointInfo.getMethod());
|
||||
|
||||
for (final HandlerInterceptor handlerInterceptor : handlerInterceptors) {
|
||||
handlerInterceptor.preHandle(httpRequest, httpResponse, endPointInfo);
|
||||
}
|
||||
|
||||
if (paramTypes.length > 0) {
|
||||
resultObj = (Result) ReflectionUtils.invokeMethod(endPointInfo.getMethod(),
|
||||
endPointInfo.getExecutor(), deSerialize);
|
||||
} else {
|
||||
resultObj = (Result) ReflectionUtils.invokeMethod(endPointInfo.getMethod(),
|
||||
endPointInfo.getExecutor());
|
||||
}
|
||||
|
||||
for (final HandlerInterceptor handlerInterceptor : handlerInterceptors) {
|
||||
handlerInterceptor.postHandle(httpRequest, httpResponse, endPointInfo);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
EasyRetryLog.LOCAL.error("http request error. [{}]", content, ex);
|
||||
resultObj = new NettyResult(0, ex.getMessage(), null, retryRequest.getReqId());
|
||||
e = ex;
|
||||
} finally {
|
||||
NettyResult nettyResult = new NettyResult();
|
||||
nettyResult.setRequestId(retryRequest.getReqId());
|
||||
if (Objects.nonNull(resultObj)) {
|
||||
nettyResult.setData(resultObj.getData());
|
||||
nettyResult.setMessage(resultObj.getMessage());
|
||||
nettyResult.setStatus(resultObj.getStatus());
|
||||
}
|
||||
|
||||
for (final HandlerInterceptor handlerInterceptor : handlerInterceptors) {
|
||||
handlerInterceptor.afterCompletion(httpRequest, httpResponse, endPointInfo, e);
|
||||
}
|
||||
|
||||
writeResponse(channelHandlerContext, HttpUtil.isKeepAlive(fullHttpRequest), httpResponse,
|
||||
JsonUtil.toJsonString(nettyResult));
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void writeResponse(ChannelHandlerContext ctx, boolean keepAlive, final HttpResponse httpResponse, String responseJson) {
|
||||
// write response
|
||||
FullHttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK,
|
||||
Unpooled.copiedBuffer(responseJson, CharsetUtil.UTF_8));
|
||||
response.headers().set(HttpHeaderNames.CONTENT_TYPE,
|
||||
HttpHeaderValues.APPLICATION_JSON);
|
||||
response.headers().set(HttpHeaderNames.CONTENT_LENGTH, response.content().readableBytes());
|
||||
if (keepAlive) {
|
||||
response.headers().set(HttpHeaderNames.CONNECTION, HttpHeaderValues.KEEP_ALIVE);
|
||||
}
|
||||
Map<String, Object> headers = httpResponse.getHeaders();
|
||||
headers.forEach((key, value) -> response.headers().set(key, value));
|
||||
ctx.writeAndFlush(response);
|
||||
}
|
||||
|
||||
public Object deSerialize(String infoStr, Method method) throws JsonProcessingException {
|
||||
|
||||
Type[] paramTypes = method.getGenericParameterTypes();
|
||||
|
||||
Object[] params = new Object[paramTypes.length];
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode jsonNode = JsonUtil.toJson(infoStr);
|
||||
if (Objects.isNull(jsonNode)) {
|
||||
EasyRetryLog.LOCAL.warn("jsonNode is null. infoStr:[{}]", infoStr);
|
||||
return params;
|
||||
}
|
||||
|
||||
for (int i = 0; i < paramTypes.length; i++) {
|
||||
JsonNode node = jsonNode.get(i);
|
||||
if (Objects.nonNull(node)) {
|
||||
params[i] = mapper.readValue(node.toString(), mapper.constructType(paramTypes[i]));
|
||||
}
|
||||
}
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
private static List<HandlerInterceptor> handlerInterceptors() {
|
||||
List<HandlerInterceptor> handlerInterceptors = ServiceLoaderUtil.loadList(HandlerInterceptor.class);
|
||||
if (CollectionUtils.isEmpty(handlerInterceptors)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return handlerInterceptors.stream().sorted(Comparator.comparingInt(HandlerInterceptor::order)).collect(
|
||||
Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.aizuda.easy.retry.client.common.netty;
|
||||
package com.aizuda.easy.retry.client.common.rpc.client;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
@ -25,7 +25,7 @@ import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author www.byteblogs.com
|
||||
* @author opensnail
|
||||
* @date 2023-05-13
|
||||
* @since 1.3.0
|
||||
*/
|
@ -1,7 +1,6 @@
|
||||
package com.aizuda.easy.retry.client.common.netty;
|
||||
package com.aizuda.easy.retry.client.common.rpc.client;
|
||||
|
||||
import com.aizuda.easy.retry.client.common.event.ChannelReconnectEvent;
|
||||
import com.aizuda.easy.retry.client.common.proxy.RequestBuilder;
|
||||
import com.aizuda.easy.retry.client.common.NettyClient;
|
||||
import com.aizuda.easy.retry.common.core.constant.SystemConstants.BEAT;
|
||||
import com.aizuda.easy.retry.common.core.context.SpringContext;
|
||||
@ -21,7 +20,7 @@ import java.util.concurrent.TimeUnit;
|
||||
/**
|
||||
* netty 客户端处理器
|
||||
*
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2022-03-07 18:30
|
||||
* @since 1.0.0
|
||||
*/
|
@ -1,7 +1,6 @@
|
||||
package com.aizuda.easy.retry.client.common.netty;
|
||||
package com.aizuda.easy.retry.client.common.rpc.client;
|
||||
|
||||
import com.aizuda.easy.retry.client.common.Lifecycle;
|
||||
import com.aizuda.easy.retry.client.common.config.EasyRetryProperties;
|
||||
import com.aizuda.easy.retry.common.log.EasyRetryLog;
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.channel.*;
|
||||
@ -11,10 +10,6 @@ import io.netty.channel.socket.nio.NioSocketChannel;
|
||||
import io.netty.handler.codec.http.*;
|
||||
import io.netty.handler.timeout.IdleStateHandler;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -27,7 +22,7 @@ import java.util.concurrent.TimeUnit;
|
||||
/**
|
||||
* Netty 客户端
|
||||
*
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2022-03-07 18:24
|
||||
* @since 1.0.0
|
||||
*/
|
@ -1,4 +1,4 @@
|
||||
package com.aizuda.easy.retry.client.common.proxy;
|
||||
package com.aizuda.easy.retry.client.common.rpc.client;
|
||||
|
||||
import com.aizuda.easy.retry.client.common.exception.EasyRetryClientException;
|
||||
|
||||
@ -10,7 +10,7 @@ import java.util.function.Consumer;
|
||||
/**
|
||||
* 构建请求类型
|
||||
*
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2023-05-12 16:47
|
||||
* @since 1.3.0
|
||||
*/
|
||||
@ -66,10 +66,10 @@ public class RequestBuilder<T, R> {
|
||||
throw new EasyRetryClientException("class not found exception to: [{}]", clintInterface.getName());
|
||||
}
|
||||
|
||||
ClientInvokeHandler<R> clientInvokeHandler = new ClientInvokeHandler<>(async, timeout, unit, callback);
|
||||
RpcClientInvokeHandler<R> rpcClientInvokeHandler = new RpcClientInvokeHandler<>(async, timeout, unit, callback);
|
||||
|
||||
return (T) Proxy.newProxyInstance(clintInterface.getClassLoader(),
|
||||
new Class[]{clintInterface}, clientInvokeHandler);
|
||||
new Class[]{clintInterface}, rpcClientInvokeHandler);
|
||||
}
|
||||
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
package com.aizuda.easy.retry.client.common.netty;
|
||||
package com.aizuda.easy.retry.client.common.rpc.client;
|
||||
|
||||
/**
|
||||
* 请求类型
|
||||
*
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2023-05-12 08:53
|
||||
* @since 1.3.0
|
||||
*/
|
||||
@ -17,6 +17,4 @@ public enum RequestMethod {
|
||||
OPTIONS,
|
||||
TRACE;
|
||||
|
||||
private RequestMethod() {
|
||||
}
|
||||
}
|
@ -1,12 +1,10 @@
|
||||
package com.aizuda.easy.retry.client.common.proxy;
|
||||
package com.aizuda.easy.retry.client.common.rpc.client;
|
||||
|
||||
import cn.hutool.core.date.StopWatch;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import com.aizuda.easy.retry.client.common.annotation.Mapping;
|
||||
import com.aizuda.easy.retry.client.common.exception.EasyRetryClientException;
|
||||
import com.aizuda.easy.retry.client.common.exception.EasyRetryClientTimeOutException;
|
||||
import com.aizuda.easy.retry.client.common.netty.NettyChannel;
|
||||
import com.aizuda.easy.retry.client.common.netty.RpcContext;
|
||||
import com.aizuda.easy.retry.common.log.EasyRetryLog;
|
||||
import com.aizuda.easy.retry.common.core.model.EasyRetryRequest;
|
||||
import io.netty.handler.codec.http.HttpMethod;
|
||||
@ -23,19 +21,19 @@ import java.util.function.Consumer;
|
||||
/**
|
||||
* 请求处理器
|
||||
*
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2023-05-11 21:45
|
||||
* @since 1.3.0
|
||||
*/
|
||||
@Slf4j
|
||||
public class ClientInvokeHandler<R> implements InvocationHandler {
|
||||
public class RpcClientInvokeHandler<R> implements InvocationHandler {
|
||||
|
||||
private final Consumer<R> consumer;
|
||||
private final boolean async;
|
||||
private final long timeout;
|
||||
private final TimeUnit unit;
|
||||
|
||||
public ClientInvokeHandler(boolean async, long timeout, TimeUnit unit, Consumer<R> consumer) {
|
||||
public RpcClientInvokeHandler(boolean async, long timeout, TimeUnit unit, Consumer<R> consumer) {
|
||||
this.consumer = consumer;
|
||||
this.async = async;
|
||||
this.timeout = timeout;
|
@ -1,7 +1,7 @@
|
||||
package com.aizuda.easy.retry.server.common.netty.client;
|
||||
package com.aizuda.easy.retry.client.common.rpc.client;
|
||||
|
||||
import com.aizuda.easy.retry.common.core.model.NettyResult;
|
||||
import com.aizuda.easy.retry.common.log.EasyRetryLog;
|
||||
import com.aizuda.easy.retry.common.core.model.NettyResult;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.Objects;
|
||||
@ -14,7 +14,7 @@ import java.util.function.Consumer;
|
||||
/**
|
||||
* 处理请求服务端时需要存储的中间值
|
||||
*
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2023-05-12 09:05
|
||||
* @since 1.3.0
|
||||
*/
|
@ -1,8 +1,10 @@
|
||||
package com.aizuda.easy.retry.client.common.netty.server;
|
||||
package com.aizuda.easy.retry.client.common.rpc.server;
|
||||
|
||||
import com.aizuda.easy.retry.client.common.Lifecycle;
|
||||
import com.aizuda.easy.retry.client.common.config.EasyRetryProperties;
|
||||
import com.aizuda.easy.retry.client.common.exception.EasyRetryClientException;
|
||||
import com.aizuda.easy.retry.client.common.rpc.supports.handler.NettyHttpServerHandler;
|
||||
import com.aizuda.easy.retry.client.common.rpc.supports.handler.SnailDispatcherRequestHandler;
|
||||
import com.aizuda.easy.retry.common.log.EasyRetryLog;
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
@ -23,16 +25,17 @@ import org.springframework.stereotype.Component;
|
||||
/**
|
||||
* netty server
|
||||
*
|
||||
* @author: www.byteblogs.com
|
||||
* @date : 2022-03-07 15:54
|
||||
* @since 1.0.0
|
||||
* @author: opensnail
|
||||
* @date : 2024-04-12 23:03
|
||||
* @since 3.3.0
|
||||
*/
|
||||
@Component
|
||||
@Order(Ordered.HIGHEST_PRECEDENCE)
|
||||
@RequiredArgsConstructor
|
||||
@Getter
|
||||
public class NettyHttpServer implements Runnable, Lifecycle {
|
||||
public class SnailNettyHttpServer implements Runnable, Lifecycle {
|
||||
private final EasyRetryProperties easyRetryProperties;
|
||||
private final SnailDispatcherRequestHandler snailDispatcherRequestHandler;
|
||||
private Thread thread = null;
|
||||
private volatile boolean started = false;
|
||||
|
||||
@ -59,7 +62,7 @@ public class NettyHttpServer implements Runnable, Lifecycle {
|
||||
channel.pipeline()
|
||||
.addLast(new HttpServerCodec())
|
||||
.addLast(new HttpObjectAggregator(5 * 1024 * 1024))
|
||||
.addLast(new NettyHttpServerHandler());
|
||||
.addLast(new NettyHttpServerHandler(snailDispatcherRequestHandler));
|
||||
}
|
||||
});
|
||||
|
||||
@ -67,7 +70,7 @@ public class NettyHttpServer implements Runnable, Lifecycle {
|
||||
ChannelFuture future = bootstrap.bind(easyRetryProperties.getPort()).sync();
|
||||
|
||||
EasyRetryLog.LOCAL.info("------> easy-retry client remoting server start success, nettype = {}, port = {}",
|
||||
NettyHttpServer.class.getName(), easyRetryProperties.getPort());
|
||||
SnailNettyHttpServer.class.getName(), easyRetryProperties.getPort());
|
||||
|
||||
started = true;
|
||||
future.channel().closeFuture().sync();
|
@ -0,0 +1,31 @@
|
||||
package com.aizuda.easy.retry.client.common.rpc.supports.handler;
|
||||
|
||||
import com.aizuda.easy.retry.client.common.rpc.supports.http.HttpRequest;
|
||||
import com.aizuda.easy.retry.client.common.rpc.supports.http.HttpResponse;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.http.HttpHeaders;
|
||||
import io.netty.handler.codec.http.HttpMethod;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* netty客户端请求模型
|
||||
*
|
||||
* @author: opensnail
|
||||
* @date : 2023-07-24 09:32
|
||||
* @since : 3.3.0
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
public class NettyHttpRequest {
|
||||
|
||||
private final ChannelHandlerContext channelHandlerContext;
|
||||
private final String content;
|
||||
private final boolean keepAlive;
|
||||
private final HttpMethod method;
|
||||
private final String uri;
|
||||
private final HttpHeaders headers;
|
||||
private final HttpResponse httpResponse;
|
||||
private final HttpRequest httpRequest;
|
||||
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
package com.aizuda.easy.retry.client.common.rpc.supports.handler;
|
||||
|
||||
import com.aizuda.easy.retry.client.common.rpc.supports.http.HttpRequest;
|
||||
import com.aizuda.easy.retry.client.common.rpc.supports.http.HttpResponse;
|
||||
import com.aizuda.easy.retry.common.core.model.EasyRetryRequest;
|
||||
import com.aizuda.easy.retry.common.core.model.NettyResult;
|
||||
import com.aizuda.easy.retry.common.core.util.JsonUtil;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
import io.netty.handler.codec.http.*;
|
||||
import io.netty.util.CharsetUtil;
|
||||
import org.springframework.scheduling.concurrent.CustomizableThreadFactory;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author: opensnail
|
||||
* @date : 2024-04-11 16:03
|
||||
* @since : 3.3.0
|
||||
*/
|
||||
public class NettyHttpServerHandler extends SimpleChannelInboundHandler<FullHttpRequest> {
|
||||
|
||||
// TODO 支持可配置
|
||||
private static final ThreadPoolExecutor DISPATCHER_THREAD_POOL = new ThreadPoolExecutor(
|
||||
16, 16, 1L, TimeUnit.SECONDS, new LinkedBlockingQueue<>(),
|
||||
new CustomizableThreadFactory("snail-netty-server-"));
|
||||
private final SnailDispatcherRequestHandler dispatcher;
|
||||
|
||||
public NettyHttpServerHandler(SnailDispatcherRequestHandler snailDispatcherRequestHandler) {
|
||||
this.dispatcher = snailDispatcherRequestHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void channelRead0(ChannelHandlerContext channelHandlerContext, FullHttpRequest fullHttpRequest) {
|
||||
|
||||
String content = fullHttpRequest.content().toString(CharsetUtil.UTF_8);
|
||||
HttpHeaders headers = fullHttpRequest.headers();
|
||||
String uri = fullHttpRequest.uri();
|
||||
NettyHttpRequest nettyHttpRequest = NettyHttpRequest.builder()
|
||||
.keepAlive(HttpUtil.isKeepAlive(fullHttpRequest))
|
||||
.uri(uri)
|
||||
.channelHandlerContext(channelHandlerContext)
|
||||
.method(fullHttpRequest.method())
|
||||
.headers(headers)
|
||||
.content(content)
|
||||
.httpResponse(new HttpResponse())
|
||||
.httpRequest(new HttpRequest(headers, uri))
|
||||
.build();
|
||||
|
||||
// 执行任务
|
||||
DISPATCHER_THREAD_POOL.execute(() -> {
|
||||
NettyResult nettyResult = null;
|
||||
try {
|
||||
nettyResult = dispatcher.dispatch(nettyHttpRequest);
|
||||
} catch (Exception e) {
|
||||
EasyRetryRequest retryRequest = JsonUtil.parseObject(content, EasyRetryRequest.class);
|
||||
nettyResult = new NettyResult(0, e.getMessage(), null, retryRequest.getReqId());
|
||||
} finally {
|
||||
writeResponse(channelHandlerContext,
|
||||
HttpUtil.isKeepAlive(fullHttpRequest),
|
||||
nettyHttpRequest.getHttpResponse(),
|
||||
JsonUtil.toJsonString(nettyResult)
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void writeResponse(ChannelHandlerContext ctx, boolean keepAlive, final HttpResponse httpResponse, String responseJson) {
|
||||
// write response
|
||||
FullHttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK,
|
||||
Unpooled.copiedBuffer(responseJson, CharsetUtil.UTF_8));
|
||||
response.headers().set(HttpHeaderNames.CONTENT_TYPE,
|
||||
HttpHeaderValues.APPLICATION_JSON);
|
||||
response.headers().set(HttpHeaderNames.CONTENT_LENGTH, response.content().readableBytes());
|
||||
if (keepAlive) {
|
||||
response.headers().set(HttpHeaderNames.CONNECTION, HttpHeaderValues.KEEP_ALIVE);
|
||||
}
|
||||
Map<String, Object> headers = httpResponse.getHeaders();
|
||||
headers.forEach((key, value) -> response.headers().set(key, value));
|
||||
ctx.writeAndFlush(response);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,154 @@
|
||||
package com.aizuda.easy.retry.client.common.rpc.supports.handler;
|
||||
|
||||
import cn.hutool.core.net.url.UrlBuilder;
|
||||
import cn.hutool.core.util.ServiceLoaderUtil;
|
||||
import com.aizuda.easy.retry.client.common.cache.EndPointInfoCache;
|
||||
import com.aizuda.easy.retry.client.common.config.EasyRetryProperties;
|
||||
import com.aizuda.easy.retry.client.common.exception.EasyRetryClientException;
|
||||
import com.aizuda.easy.retry.client.common.intercepter.HandlerInterceptor;
|
||||
import com.aizuda.easy.retry.client.common.rpc.client.RequestMethod;
|
||||
import com.aizuda.easy.retry.client.common.rpc.supports.scan.EndPointInfo;
|
||||
import com.aizuda.easy.retry.client.common.rpc.supports.http.HttpRequest;
|
||||
import com.aizuda.easy.retry.client.common.rpc.supports.http.HttpResponse;
|
||||
import com.aizuda.easy.retry.common.core.constant.SystemConstants;
|
||||
import com.aizuda.easy.retry.common.core.enums.StatusEnum;
|
||||
import com.aizuda.easy.retry.common.core.model.EasyRetryRequest;
|
||||
import com.aizuda.easy.retry.common.core.model.NettyResult;
|
||||
import com.aizuda.easy.retry.common.core.model.Result;
|
||||
import com.aizuda.easy.retry.common.core.util.JsonUtil;
|
||||
import com.aizuda.easy.retry.common.log.EasyRetryLog;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Parameter;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author: opensnail
|
||||
* @date : 2024-04-12
|
||||
* @since : 3.3.0
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class SnailDispatcherRequestHandler {
|
||||
private final EasyRetryProperties easyRetryProperties;
|
||||
|
||||
public NettyResult dispatch(NettyHttpRequest request) {
|
||||
|
||||
NettyResult nettyResult = new NettyResult();
|
||||
|
||||
List<HandlerInterceptor> handlerInterceptors = handlerInterceptors();
|
||||
EasyRetryRequest retryRequest = JsonUtil.parseObject(request.getContent(), EasyRetryRequest.class);
|
||||
HttpRequest httpRequest = request.getHttpRequest();
|
||||
HttpResponse httpResponse = request.getHttpResponse();
|
||||
EndPointInfo endPointInfo = null;
|
||||
Result resultObj = null;
|
||||
Exception e = null;
|
||||
try {
|
||||
String easyRetryAuth = request.getHeaders().getAsString(SystemConstants.EASY_RETRY_AUTH_TOKEN);
|
||||
String configToken = Optional.ofNullable(easyRetryProperties.getToken()).orElse(SystemConstants.DEFAULT_TOKEN);
|
||||
if (!configToken.equals(easyRetryAuth)) {
|
||||
throw new EasyRetryClientException("认证失败.【请检查配置的Token是否正确】");
|
||||
}
|
||||
|
||||
UrlBuilder builder = UrlBuilder.ofHttp(request.getUri());
|
||||
RequestMethod requestMethod = RequestMethod.valueOf(request.getMethod().name());
|
||||
|
||||
endPointInfo = EndPointInfoCache.get(builder.getPathStr(), requestMethod);
|
||||
Class<?>[] paramTypes = endPointInfo.getMethod().getParameterTypes();
|
||||
Object[] args = retryRequest.getArgs();
|
||||
|
||||
Object[] deSerialize = (Object[]) deSerialize(JsonUtil.toJsonString(args), endPointInfo.getMethod(),
|
||||
httpRequest, httpResponse);
|
||||
|
||||
for (final HandlerInterceptor handlerInterceptor : handlerInterceptors) {
|
||||
if (!handlerInterceptor.preHandle(httpRequest, httpResponse, endPointInfo)) {
|
||||
return nettyResult;
|
||||
}
|
||||
}
|
||||
|
||||
if (paramTypes.length > 0) {
|
||||
resultObj = (Result) ReflectionUtils.invokeMethod(endPointInfo.getMethod(),
|
||||
endPointInfo.getExecutor(), deSerialize);
|
||||
} else {
|
||||
resultObj = (Result) ReflectionUtils.invokeMethod(endPointInfo.getMethod(),
|
||||
endPointInfo.getExecutor());
|
||||
}
|
||||
|
||||
for (final HandlerInterceptor handlerInterceptor : handlerInterceptors) {
|
||||
handlerInterceptor.postHandle(httpRequest, httpResponse, endPointInfo);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
EasyRetryLog.LOCAL.error("http request error. [{}]", request.getContent(), ex);
|
||||
nettyResult.setMessage(ex.getMessage()).setStatus(StatusEnum.NO.getStatus());
|
||||
e = ex;
|
||||
} finally {
|
||||
nettyResult.setRequestId(retryRequest.getReqId());
|
||||
if (Objects.nonNull(resultObj)) {
|
||||
nettyResult.setData(resultObj.getData())
|
||||
.setMessage(resultObj.getMessage())
|
||||
.setStatus(resultObj.getStatus());
|
||||
}
|
||||
|
||||
for (final HandlerInterceptor handlerInterceptor : handlerInterceptors) {
|
||||
handlerInterceptor.afterCompletion(httpRequest, httpResponse, endPointInfo, e);
|
||||
}
|
||||
}
|
||||
|
||||
return nettyResult;
|
||||
}
|
||||
|
||||
private static List<HandlerInterceptor> handlerInterceptors() {
|
||||
List<HandlerInterceptor> handlerInterceptors = ServiceLoaderUtil.loadList(HandlerInterceptor.class);
|
||||
if (CollectionUtils.isEmpty(handlerInterceptors)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return handlerInterceptors.stream().sorted(Comparator.comparingInt(HandlerInterceptor::order)).collect(
|
||||
Collectors.toList());
|
||||
}
|
||||
|
||||
public Object deSerialize(String infoStr, Method method,
|
||||
HttpRequest httpRequest, HttpResponse httpResponse) throws JsonProcessingException {
|
||||
|
||||
Type[] paramTypes = method.getGenericParameterTypes();
|
||||
Parameter[] parameters = method.getParameters();
|
||||
Object[] params = new Object[paramTypes.length];
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode jsonNode = JsonUtil.toJson(infoStr);
|
||||
if (Objects.isNull(jsonNode)) {
|
||||
EasyRetryLog.LOCAL.warn("jsonNode is null. infoStr:[{}]", infoStr);
|
||||
return params;
|
||||
}
|
||||
|
||||
for (int i = 0; i < paramTypes.length; i++) {
|
||||
JsonNode node = jsonNode.get(i);
|
||||
if (Objects.nonNull(node)) {
|
||||
params[i] = mapper.readValue(node.toString(), mapper.constructType(paramTypes[i]));
|
||||
continue;
|
||||
}
|
||||
|
||||
Parameter parameter = parameters[i];
|
||||
if (parameter.getType().isAssignableFrom(HttpRequest.class)) {
|
||||
params[i] = httpRequest;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (parameter.getType().isAssignableFrom(HttpResponse.class)) {
|
||||
params[i] = httpResponse;
|
||||
}
|
||||
}
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.aizuda.easy.retry.client.common.rpc.supports.http;
|
||||
|
||||
import io.netty.handler.codec.http.HttpHeaders;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author: opensnail
|
||||
* @date : 2024-04-12
|
||||
* @since : 3.3.0
|
||||
*/
|
||||
@Data
|
||||
public class HttpRequest {
|
||||
private final HttpHeaders headers;
|
||||
private final String uri;
|
||||
|
||||
public HttpRequest(HttpHeaders headers, String uri) {
|
||||
this.headers = headers;
|
||||
this.uri = uri;
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.aizuda.easy.retry.client.common.netty.server;
|
||||
package com.aizuda.easy.retry.client.common.rpc.supports.http;
|
||||
|
||||
import lombok.Data;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.aizuda.easy.retry.client.common.netty.server;
|
||||
package com.aizuda.easy.retry.client.common.rpc.supports.scan;
|
||||
|
||||
import com.aizuda.easy.retry.client.common.netty.RequestMethod;
|
||||
import com.aizuda.easy.retry.client.common.rpc.client.RequestMethod;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.aizuda.easy.retry.client.common.netty.server;
|
||||
package com.aizuda.easy.retry.client.common.rpc.supports.scan;
|
||||
|
||||
import com.aizuda.easy.retry.client.common.Lifecycle;
|
||||
import com.aizuda.easy.retry.client.common.cache.EndPointInfoCache;
|
||||
import com.aizuda.easy.retry.client.common.exception.EasyRetryClientException;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
@ -1,4 +1,4 @@
|
||||
package com.aizuda.easy.retry.client.common.netty.server;
|
||||
package com.aizuda.easy.retry.client.common.rpc.supports.scan;
|
||||
|
||||
import com.aizuda.easy.retry.client.common.annotation.Mapping;
|
||||
import com.aizuda.easy.retry.client.common.annotation.SnailEndPoint;
|
@ -16,7 +16,7 @@ import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
/**
|
||||
* 通过滑动窗口上报异常数据
|
||||
*
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2022-05-28 15:07
|
||||
*/
|
||||
@Slf4j
|
||||
|
@ -18,7 +18,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
/**
|
||||
* 滑动窗口组件
|
||||
*
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2023-07-23 13:38
|
||||
* @since 2.1.0
|
||||
*/
|
||||
|
@ -14,7 +14,7 @@ import com.aizuda.easy.retry.common.core.model.IdempotentIdContext;
|
||||
* 时刻4: idempotentId: A1 重试完成, 状态为已完成
|
||||
* 时刻5: 上报一个异常 idempotentId: A1 状态为重试中, 新增一条重试任务
|
||||
*
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2022-03-08 09:42
|
||||
*/
|
||||
public interface IdempotentIdGenerate {
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.aizuda.easy.retry.client.core;
|
||||
|
||||
/**
|
||||
* @author www.byteblogs.com
|
||||
* @author opensnail
|
||||
* @date 2023-05-15
|
||||
* @since 2.0
|
||||
*/
|
||||
|
@ -5,7 +5,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2022-03-07 15:08
|
||||
*/
|
||||
public interface RetryArgSerializer {
|
||||
|
@ -7,7 +7,7 @@ import java.util.concurrent.Callable;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2022-03-03 14:54
|
||||
*/
|
||||
public interface RetryExecutor<BR, SR> {
|
||||
|
@ -5,7 +5,7 @@ import com.github.rholder.retry.RetryListener;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2022-03-04 09:03
|
||||
*/
|
||||
public interface RetryExecutorParameter<BR, SR> {
|
||||
|
@ -3,7 +3,7 @@ package com.aizuda.easy.retry.client.core;
|
||||
/**
|
||||
* 手动生成重试任务模板类
|
||||
*
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2023-05-09 16:32
|
||||
*/
|
||||
public interface RetryOperations {
|
||||
|
@ -6,7 +6,7 @@ import com.aizuda.easy.retry.client.core.intercepter.ThreadLockRetrySiteSnapshot
|
||||
* 重试现场记录上下文
|
||||
* 默认实现see: {@link ThreadLockRetrySiteSnapshotContext}
|
||||
*
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2023-08-09 16:25
|
||||
*/
|
||||
public interface RetrySiteSnapshotContext<T> {
|
||||
|
@ -5,7 +5,7 @@ import com.aizuda.easy.retry.client.core.retryer.RetryerInfo;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2022-02-10 09:13
|
||||
*/
|
||||
public interface Scanner {
|
||||
|
@ -17,7 +17,7 @@ import java.util.concurrent.TimeUnit;
|
||||
/**
|
||||
* 在使用手动生成重试任务时,通过ExecutorMethodRegister配置注册重试场景
|
||||
*
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2023-05-10 09:39
|
||||
* @since 1.3.0
|
||||
*/
|
||||
|
@ -15,7 +15,7 @@ import java.util.concurrent.TimeUnit;
|
||||
/**
|
||||
* 重试接入入口
|
||||
*
|
||||
* @author www.byteblogs.com
|
||||
* @author opensnail
|
||||
*/
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
|
@ -5,7 +5,7 @@ import com.google.common.collect.Table;
|
||||
import com.aizuda.easy.retry.client.core.retryer.RetryerInfo;
|
||||
|
||||
/**
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2022-03-03 17:43
|
||||
*/
|
||||
public class RetryerInfoCache {
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.aizuda.easy.retry.client.core.callback;
|
||||
|
||||
/**
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2023-01-10 14:46
|
||||
*/
|
||||
public interface RetryCompleteCallback {
|
||||
|
@ -4,7 +4,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2023-01-10 14:47
|
||||
*/
|
||||
@Component
|
||||
|
@ -4,7 +4,7 @@ import cn.hutool.core.lang.Assert;
|
||||
import com.aizuda.easy.retry.client.common.annotation.Mapping;
|
||||
import com.aizuda.easy.retry.client.common.annotation.SnailEndPoint;
|
||||
import com.aizuda.easy.retry.client.common.log.support.EasyRetryLogManager;
|
||||
import com.aizuda.easy.retry.client.common.netty.RequestMethod;
|
||||
import com.aizuda.easy.retry.client.common.rpc.client.RequestMethod;
|
||||
import com.aizuda.easy.retry.client.core.IdempotentIdGenerate;
|
||||
import com.aizuda.easy.retry.client.core.RetryArgSerializer;
|
||||
import com.aizuda.easy.retry.client.common.cache.GroupVersionCache;
|
||||
@ -49,7 +49,7 @@ import java.util.Set;
|
||||
/**
|
||||
* 服务端调调用客户端进行重试流量下发、配置变更通知等操作
|
||||
*
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2022-03-09 16:33
|
||||
*/
|
||||
@SnailEndPoint
|
||||
|
@ -3,7 +3,7 @@ package com.aizuda.easy.retry.client.core.event;
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2022-03-03 15:50
|
||||
*/
|
||||
public interface EasyRetryListener {
|
||||
|
@ -5,7 +5,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2022-03-04 16:55
|
||||
*/
|
||||
@Slf4j
|
||||
|
@ -3,7 +3,7 @@ package com.aizuda.easy.retry.client.core.exception;
|
||||
import com.aizuda.easy.retry.common.core.exception.BaseEasyRetryException;
|
||||
|
||||
/**
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2022-03-03 14:49
|
||||
*/
|
||||
public class EasyRetryClientException extends BaseEasyRetryException {
|
||||
|
@ -3,7 +3,7 @@ package com.aizuda.easy.retry.client.core.exception;
|
||||
import com.aizuda.easy.retry.common.core.exception.BaseEasyRetryException;
|
||||
|
||||
/**
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2022-03-03 14:49
|
||||
*/
|
||||
public class EasyRetryClientTimeOutException extends BaseEasyRetryException {
|
||||
|
@ -10,7 +10,7 @@ import com.aizuda.easy.retry.common.core.util.JsonUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2022-03-03 18:08
|
||||
*/
|
||||
@Slf4j
|
||||
|
@ -19,7 +19,7 @@ import java.util.function.Consumer;
|
||||
/**
|
||||
* Guava 重试执行器
|
||||
*
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2022-03-03 18:07
|
||||
* @since 1.3.0
|
||||
*/
|
||||
|
@ -7,7 +7,7 @@ import com.aizuda.easy.retry.common.core.model.IdempotentIdContext;
|
||||
/**
|
||||
* 默认的idempotentId 生成器
|
||||
*
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2022-03-08 09:42
|
||||
*/
|
||||
public class SimpleIdempotentIdGenerate implements IdempotentIdGenerate {
|
||||
|
@ -43,7 +43,7 @@ import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author www.byteblogs.com
|
||||
* @author opensnail
|
||||
* @date 2023-08-23
|
||||
*/
|
||||
@Slf4j
|
||||
|
@ -24,7 +24,7 @@ import java.lang.reflect.Method;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
/**
|
||||
* @author www.byteblogs.com
|
||||
* @author opensnail
|
||||
* @date 2023-08-23
|
||||
*/
|
||||
//@Configuration
|
||||
|
@ -19,7 +19,7 @@ import java.util.Objects;
|
||||
/**
|
||||
* 服务间调用传递请求头和响应头
|
||||
*
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2022-04-18 09:19
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
@ -17,7 +17,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
/**
|
||||
* 重试现场记录器
|
||||
*
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2022-03-03 13:42
|
||||
*/
|
||||
public class RetrySiteSnapshot {
|
||||
|
@ -7,7 +7,7 @@ import com.aizuda.easy.retry.client.core.exception.EasyRetryClientException;
|
||||
/**
|
||||
* ThreadLocal实现类
|
||||
*
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2023-08-09 16:34
|
||||
* @since 2.2.0
|
||||
*/
|
||||
|
@ -21,7 +21,7 @@ import java.util.Optional;
|
||||
/**
|
||||
* Easy Retry Spi加载器
|
||||
*
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2023-08-07 18:05
|
||||
* @since 2.2.0
|
||||
*/
|
||||
|
@ -13,7 +13,7 @@ import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2022-05-17 09:01
|
||||
*/
|
||||
@Slf4j
|
||||
|
@ -7,7 +7,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2022-05-17 09:01
|
||||
*/
|
||||
public class ResponseHeaderPlugins {
|
||||
|
@ -12,7 +12,7 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2022-02-10 09:12
|
||||
*/
|
||||
@Component
|
||||
|
@ -28,7 +28,7 @@ import java.util.concurrent.TimeUnit;
|
||||
/**
|
||||
* 扫描手动注入重试方法
|
||||
*
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2023-05-10 11:10
|
||||
*/
|
||||
@Component
|
||||
|
@ -26,7 +26,7 @@ import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2022-03-03 16:55
|
||||
*/
|
||||
@Component
|
||||
|
@ -22,7 +22,7 @@ import java.lang.reflect.Method;
|
||||
/**
|
||||
* 上报抽象类
|
||||
*
|
||||
* @author www.byteblogs.com
|
||||
* @author opensnail
|
||||
* @date 2023-05-15
|
||||
* @since 1.3.0
|
||||
*/
|
||||
|
@ -16,7 +16,7 @@ import java.util.concurrent.TimeUnit;
|
||||
/**
|
||||
* 异步上报数据
|
||||
*
|
||||
* @author www.byteblogs.com
|
||||
* @author opensnail
|
||||
* @date 2023-05-15
|
||||
* @since 1.3.0
|
||||
*/
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.aizuda.easy.retry.client.core.report;
|
||||
|
||||
import com.aizuda.easy.retry.client.common.config.EasyRetryProperties;
|
||||
import com.aizuda.easy.retry.client.common.proxy.RequestBuilder;
|
||||
import com.aizuda.easy.retry.client.common.rpc.client.RequestBuilder;
|
||||
import com.aizuda.easy.retry.client.core.RetryExecutor;
|
||||
import com.aizuda.easy.retry.client.core.RetryExecutorParameter;
|
||||
import com.aizuda.easy.retry.client.common.cache.GroupVersionCache;
|
||||
@ -33,7 +33,7 @@ import java.util.concurrent.TimeUnit;
|
||||
/**
|
||||
* 批量异步上报
|
||||
*
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2022-03-08 13:54
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
@ -2,7 +2,7 @@ package com.aizuda.easy.retry.client.core.report;
|
||||
|
||||
import com.aizuda.easy.retry.client.common.cache.GroupVersionCache;
|
||||
import com.aizuda.easy.retry.client.common.config.EasyRetryProperties;
|
||||
import com.aizuda.easy.retry.client.common.proxy.RequestBuilder;
|
||||
import com.aizuda.easy.retry.client.common.rpc.client.RequestBuilder;
|
||||
import com.aizuda.easy.retry.client.common.client.NettyClient;
|
||||
import com.aizuda.easy.retry.client.core.retryer.RetryerInfo;
|
||||
import com.aizuda.easy.retry.common.core.alarm.Alarm;
|
||||
@ -30,7 +30,7 @@ import java.util.concurrent.TimeUnit;
|
||||
/**
|
||||
* 同步上报数据
|
||||
*
|
||||
* @author www.byteblogs.com
|
||||
* @author opensnail
|
||||
* @date 2023-05-15
|
||||
* @since 1.3.0
|
||||
*/
|
||||
|
@ -12,7 +12,7 @@ import java.util.Objects;
|
||||
/**
|
||||
* 手动生成重试任务模板类
|
||||
*
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2023-05-09 16:30
|
||||
* @since 1.3.0
|
||||
*/
|
||||
|
@ -9,7 +9,7 @@ import com.aizuda.easy.retry.common.core.context.SpringContext;
|
||||
/**
|
||||
* 构建重试模板对象
|
||||
*
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2023-05-10 10:17
|
||||
*/
|
||||
public class RetryTaskTemplateBuilder {
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.aizuda.easy.retry.client.core.retryer;
|
||||
|
||||
/**
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2022-03-03 15:14
|
||||
*/
|
||||
public enum RetryType {
|
||||
|
@ -13,7 +13,7 @@ import java.util.concurrent.TimeUnit;
|
||||
/**
|
||||
* 定义重试场景的信息
|
||||
*
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2022-03-03 15:06
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
@ -4,7 +4,7 @@ import com.aizuda.easy.retry.common.core.enums.RetryResultStatusEnum;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2022-03-04 14:52
|
||||
*/
|
||||
@Data
|
||||
|
@ -15,7 +15,7 @@ import java.util.Objects;
|
||||
/**
|
||||
* Hessian序列化
|
||||
*
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2022-03-07 15:08
|
||||
*/
|
||||
public class HessianSerializer implements RetryArgSerializer {
|
||||
|
@ -16,7 +16,7 @@ import java.util.Objects;
|
||||
/**
|
||||
* Jackson序列化
|
||||
*
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2022-03-07 15:08
|
||||
*/
|
||||
@Slf4j
|
||||
|
@ -34,7 +34,7 @@ import java.util.concurrent.Callable;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2022-03-04 14:40
|
||||
*/
|
||||
@Slf4j
|
||||
|
@ -7,7 +7,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
/**
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2022-03-04 17:18
|
||||
*/
|
||||
@Slf4j
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.aizuda.easy.retry.client.core.strategy;
|
||||
|
||||
/**
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2022-03-03 15:43
|
||||
*/
|
||||
public interface ExecutorMethod {
|
||||
|
@ -27,7 +27,7 @@ import java.util.function.Consumer;
|
||||
/**
|
||||
* 执行本地重试
|
||||
*
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2022-03-03 14:38
|
||||
* @since 1.3.0
|
||||
*/
|
||||
|
@ -27,7 +27,7 @@ import java.util.function.Consumer;
|
||||
/**
|
||||
* 手动执行重试
|
||||
*
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2023-05-15 18:19
|
||||
*/
|
||||
@Component
|
||||
|
@ -26,7 +26,7 @@ import java.util.function.Consumer;
|
||||
/**
|
||||
* 执行远程重试
|
||||
*
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2022-03-03 14:38
|
||||
* @since 1.3.0
|
||||
*/
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.aizuda.easy.retry.client.core.strategy;
|
||||
|
||||
/**
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2022-03-03 15:43
|
||||
*/
|
||||
public interface RetryResult {
|
||||
|
@ -4,7 +4,7 @@ import com.aizuda.easy.retry.client.core.retryer.RetryType;
|
||||
import com.aizuda.easy.retry.client.core.retryer.RetryerResultContext;
|
||||
|
||||
/**
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2022-03-03 14:33
|
||||
*/
|
||||
public interface RetryStrategy {
|
||||
|
@ -6,7 +6,7 @@ import com.aizuda.easy.retry.common.core.model.JobContext;
|
||||
/**
|
||||
* job执行者
|
||||
*
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2023-09-27 09:38
|
||||
* @since 2.4.0
|
||||
*/
|
||||
|
@ -6,7 +6,7 @@ import com.aizuda.easy.retry.client.job.core.dto.JobExecutorInfo;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2022-02-10 09:13
|
||||
*/
|
||||
public interface Scanner {
|
||||
|
@ -5,7 +5,7 @@ import java.lang.annotation.*;
|
||||
/**
|
||||
* job执行者
|
||||
*
|
||||
* @author www.byteblogs.com
|
||||
* @author opensnail
|
||||
* @date 2023-09-26 23:19:01
|
||||
* @since 2.4.0
|
||||
*/
|
||||
|
@ -12,7 +12,7 @@ import java.util.Optional;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* @author www.byteblogs.com
|
||||
* @author opensnail
|
||||
* @date 2023-10-08 23:03:53
|
||||
* @since 2.4.0
|
||||
*/
|
||||
|
@ -6,7 +6,7 @@ import java.util.Objects;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2022-03-03 17:43
|
||||
* @since : 2.4.0
|
||||
*/
|
||||
|
@ -14,7 +14,7 @@ import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2023-09-27 17:12
|
||||
* @since : 2.4.0
|
||||
*/
|
||||
|
@ -3,7 +3,7 @@ package com.aizuda.easy.retry.client.job.core.client;
|
||||
import com.aizuda.easy.retry.client.common.annotation.Mapping;
|
||||
import com.aizuda.easy.retry.client.common.annotation.SnailEndPoint;
|
||||
import com.aizuda.easy.retry.client.common.log.support.EasyRetryLogManager;
|
||||
import com.aizuda.easy.retry.client.common.netty.RequestMethod;
|
||||
import com.aizuda.easy.retry.client.common.rpc.client.RequestMethod;
|
||||
import com.aizuda.easy.retry.client.job.core.IJobExecutor;
|
||||
import com.aizuda.easy.retry.client.job.core.cache.JobExecutorInfoCache;
|
||||
import com.aizuda.easy.retry.client.job.core.cache.ThreadPoolCache;
|
||||
@ -11,7 +11,6 @@ import com.aizuda.easy.retry.client.job.core.dto.JobExecutorInfo;
|
||||
import com.aizuda.easy.retry.client.job.core.executor.AbstractJobExecutor;
|
||||
import com.aizuda.easy.retry.client.job.core.executor.AnnotationJobExecutor;
|
||||
import com.aizuda.easy.retry.client.job.core.log.JobLogMeta;
|
||||
import com.aizuda.easy.retry.client.model.DispatchRetryDTO;
|
||||
import com.aizuda.easy.retry.client.model.StopJobDTO;
|
||||
import com.aizuda.easy.retry.client.model.request.DispatchJobRequest;
|
||||
import com.aizuda.easy.retry.common.core.context.SpringContext;
|
||||
@ -23,15 +22,13 @@ import jakarta.validation.ConstraintViolation;
|
||||
import jakarta.validation.Validation;
|
||||
import jakarta.validation.Validator;
|
||||
import jakarta.validation.ValidatorFactory;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
/**
|
||||
* @author: www.byteblogs.com
|
||||
* @author: opensnail
|
||||
* @date : 2023-09-27 16:33
|
||||
*/
|
||||
@SnailEndPoint
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user