feat: 2.0.0

1. 删除GuavaRetry的retryIfException
This commit is contained in:
byteblogs168 2023-06-20 13:37:10 +08:00
parent 4e3aec94c2
commit b19bc2afb8
7 changed files with 0 additions and 47 deletions

View File

@ -1,7 +1,6 @@
package com.aizuda.easy.retry.client.core;
import com.github.rholder.retry.RetryListener;
import com.google.common.base.Predicate;
import java.util.List;
@ -11,8 +10,6 @@ import java.util.List;
*/
public interface RetryExecutorParameter<BR, SR> {
Predicate<Throwable> exceptionPredicate();
BR backOff();
SR stop();

View File

@ -33,7 +33,6 @@ public class GuavaRetryExecutor extends AbstractRetryExecutor<WaitStrategy, Stop
public Retryer build(RetryExecutorParameter<WaitStrategy, StopStrategy> parameter) {
RetryerBuilder<Object> retryerBuilder = RetryerBuilder.newBuilder();
retryerBuilder.retryIfException(throwable -> parameter.exceptionPredicate().apply(throwable));
retryerBuilder.withWaitStrategy(parameter.backOff());
retryerBuilder.withStopStrategy(parameter.stop());
for (RetryListener retryListener : parameter.getRetryListeners()) {

View File

@ -76,11 +76,6 @@ public class ReportListener implements Listener<RetryTaskDTO> {
public RetryExecutorParameter<WaitStrategy, StopStrategy> getRetryExecutorParameter() {
return new RetryExecutorParameter<WaitStrategy, StopStrategy>() {
@Override
public Predicate<Throwable> exceptionPredicate() {
return throwable -> Boolean.TRUE;
}
@Override
public WaitStrategy backOff() {
return WaitStrategies.fixedWait(2, TimeUnit.SECONDS);

View File

@ -127,30 +127,6 @@ public abstract class AbstractRetryStrategies implements RetryStrategy {
protected abstract Consumer<Throwable> doGetRetryErrorConsumer(RetryerInfo retryerInfo, Object[] params);
protected abstract Callable doGetCallable(RetryExecutor<WaitStrategy, StopStrategy> retryExecutor,Object[] params);
protected abstract RetryExecutorParameter<WaitStrategy, StopStrategy> getRetryExecutorParameter(RetryerInfo retryerInfo);
protected boolean validate(Class<? extends Throwable> throwable,RetryerInfo retryerInfo) {
Set<Class<? extends Throwable>> exclude = retryerInfo.getExclude();
Set<Class<? extends Throwable>> include = retryerInfo.getInclude();
if (CollectionUtils.isEmpty(include) && CollectionUtils.isEmpty(exclude)) {
return true;
}
for (Class<? extends Throwable> e : include) {
if (e.isAssignableFrom(throwable)) {
return true;
}
}
if (!CollectionUtils.isEmpty(exclude)) {
for (Class<? extends Throwable> e : exclude) {
if (e.isAssignableFrom(throwable)) {
return false;
}
}
return true;
}
return false;
}
/**
* 上报数据
*

View File

@ -128,11 +128,6 @@ public class LocalRetryStrategies extends AbstractRetryStrategies {
return new RetryExecutorParameter<WaitStrategy, StopStrategy>() {
@Override
public Predicate<Throwable> exceptionPredicate() {
return throwable -> LocalRetryStrategies.super.validate(throwable.getClass(), retryerInfo);
}
@Override
public WaitStrategy backOff() {
return WaitStrategies.fixedWait(retryerInfo.getLocalInterval(), TimeUnit.SECONDS);

View File

@ -95,11 +95,6 @@ public class ManualRetryStrategies extends AbstractRetryStrategies {
protected RetryExecutorParameter<WaitStrategy, StopStrategy> getRetryExecutorParameter(RetryerInfo retryerInfo) {
return new RetryExecutorParameter<WaitStrategy, StopStrategy>() {
@Override
public Predicate<Throwable> exceptionPredicate() {
return throwable -> ManualRetryStrategies.super.validate(throwable.getClass(), retryerInfo);
}
@Override
public WaitStrategy backOff() {
return WaitStrategies.fixedWait(500, TimeUnit.MILLISECONDS);

View File

@ -92,10 +92,6 @@ public class RemoteRetryStrategies extends AbstractRetryStrategies {
@Override
protected RetryExecutorParameter<WaitStrategy, StopStrategy> getRetryExecutorParameter(RetryerInfo retryerInfo) {
return new RetryExecutorParameter<WaitStrategy, StopStrategy>() {
@Override
public Predicate<Throwable> exceptionPredicate() {
return throwable -> RemoteRetryStrategies.super.validate(throwable.getClass(), retryerInfo);
}
@Override
public WaitStrategy backOff() {