code optimization & correct comment (#722)

* code optimization & correct comment

* update changelog
pull/725/head
DerekYRC 2 years ago committed by GitHub
parent d6b3ee8062
commit a13ddc4c01
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -11,4 +11,5 @@
- [Optimize: remote deprecated method](https://github.com/Tencent/spring-cloud-tencent/pull/697)
- [Test:support environment variable metadata test](https://github.com/Tencent/spring-cloud-tencent/pull/698)
- [Test: remote deprecated method in test](https://github.com/Tencent/spring-cloud-tencent/pull/706)
- [docs:update README.](https://github.com/Tencent/spring-cloud-tencent/pull/718)
- [docs:update README.](https://github.com/Tencent/spring-cloud-tencent/pull/718)
- [Code optimization & correct comment](https://github.com/Tencent/spring-cloud-tencent/pull/722)

@ -59,7 +59,7 @@ public class PolarisCircuitBreakerAutoConfiguration {
// Turn on circuitbreaker configuration
configuration.getConsumer().getCircuitBreaker().setEnable(true);
// Set excludeCircuitBreakInstances to false
// Set excludeCircuitBreakInstances to true
RecoverRouterConfig recoverRouterConfig = configuration.getConsumer().getServiceRouter()
.getPluginConfig(ServiceRouterConfig.DEFAULT_ROUTER_RECOVER, RecoverRouterConfig.class);

@ -21,6 +21,7 @@ import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
@ -33,6 +34,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.DisposableBean;
/**
* Spring value auto registry.
@ -43,13 +45,14 @@ import org.springframework.beans.factory.BeanFactory;
*
* @author weihubeats 2022-7-10
*/
public class SpringValueRegistry {
public class SpringValueRegistry implements DisposableBean {
private static final Logger logger = LoggerFactory.getLogger(SpringValueRegistry.class);
private static final long CLEAN_INTERVAL_IN_SECONDS = 5;
private final Map<BeanFactory, Multimap<String, SpringValue>> registry = Maps.newConcurrentMap();
private final AtomicBoolean initialized = new AtomicBoolean(false);
private final Object LOCK = new Object();
private ScheduledExecutorService executor;
public void register(BeanFactory beanFactory, String key, SpringValue springValue) {
if (!registry.containsKey(beanFactory)) {
@ -77,8 +80,9 @@ public class SpringValueRegistry {
}
private void initialize() {
Executors.newSingleThreadScheduledExecutor(
new NamedThreadFactory("polaris-spring-value-registry")).scheduleAtFixedRate(
executor = Executors.newSingleThreadScheduledExecutor(
new NamedThreadFactory("polaris-spring-value-registry"));
executor.scheduleAtFixedRate(
() -> {
try {
scanAndClean();
@ -97,4 +101,9 @@ public class SpringValueRegistry {
springValues.entries().removeIf(springValue -> !springValue.getValue().isTargetBeanValid());
}
}
@Override
public void destroy() throws Exception {
executor.shutdown();
}
}

@ -181,6 +181,7 @@ public class PolarisReactiveLoadBalancerClientFilter extends ReactiveLoadBalance
new ResponseData(exchange.getResponse(), new RequestData(exchange.getRequest()))))));
}
@Override
protected URI reconstructURI(ServiceInstance serviceInstance, URI original) {
return LoadBalancerUriTools.reconstructURI(serviceInstance, original);
}

Loading…
Cancel
Save