fix: beautify ServicesEagerLoadSmartLifecycle logging. (#1774)

Signed-off-by: Haotian Zhang <928016560@qq.com>
2023
Fishtail 2 days ago committed by Haotian Zhang
parent 1c68600fde
commit 801e8c28bf

@ -44,3 +44,4 @@
- [feat: support TagUtils, ContextToHeaderInterceptor in TSF.](https://github.com/Tencent/spring-cloud-tencent/pull/1754) - [feat: support TagUtils, ContextToHeaderInterceptor in TSF.](https://github.com/Tencent/spring-cloud-tencent/pull/1754)
- [fix: send unit header in tsf gw.](https://github.com/Tencent/spring-cloud-tencent/pull/1758) - [fix: send unit header in tsf gw.](https://github.com/Tencent/spring-cloud-tencent/pull/1758)
- [feat: add new key for java agent nacos discovery.](https://github.com/Tencent/spring-cloud-tencent/pull/1769) - [feat: add new key for java agent nacos discovery.](https://github.com/Tencent/spring-cloud-tencent/pull/1769)
- [fix: beautify ServicesEagerLoadSmartLifecycle logging.](https://github.com/Tencent/spring-cloud-tencent/pull/1774)

@ -44,9 +44,9 @@ public class PolarisEagerLoadAutoConfiguration {
@Bean @Bean
@ConditionalOnProperty(name = "spring.cloud.polaris.discovery.eager-load.services.enabled", havingValue = "true", matchIfMissing = true) @ConditionalOnProperty(name = "spring.cloud.polaris.discovery.eager-load.services.enabled", havingValue = "true", matchIfMissing = true)
public ServicesEagerLoadSmartLifecycle serviceEagerLoadSmartLifecycle( public ServicesEagerLoadSmartLifecycle serviceEagerLoadSmartLifecycle(
ApplicationContext applicationContext, @Autowired(required = false) PolarisDiscoveryClient polarisDiscoveryClient, @Autowired(required = false) PolarisDiscoveryClient polarisDiscoveryClient,
@Autowired(required = false) PolarisReactiveDiscoveryClient polarisReactiveDiscoveryClient) { @Autowired(required = false) PolarisReactiveDiscoveryClient polarisReactiveDiscoveryClient) {
return new ServicesEagerLoadSmartLifecycle(applicationContext, polarisDiscoveryClient, polarisReactiveDiscoveryClient); return new ServicesEagerLoadSmartLifecycle(polarisDiscoveryClient, polarisReactiveDiscoveryClient);
} }
} }

@ -24,22 +24,18 @@ import com.tencent.cloud.polaris.discovery.reactive.PolarisReactiveDiscoveryClie
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.SmartLifecycle; import org.springframework.context.SmartLifecycle;
public class ServicesEagerLoadSmartLifecycle implements SmartLifecycle { public class ServicesEagerLoadSmartLifecycle implements SmartLifecycle {
private static final Logger LOG = LoggerFactory.getLogger(ServicesEagerLoadSmartLifecycle.class); private static final Logger LOG = LoggerFactory.getLogger(ServicesEagerLoadSmartLifecycle.class);
private final ApplicationContext applicationContext;
private final PolarisDiscoveryClient polarisDiscoveryClient; private final PolarisDiscoveryClient polarisDiscoveryClient;
private final PolarisReactiveDiscoveryClient polarisReactiveDiscoveryClient; private final PolarisReactiveDiscoveryClient polarisReactiveDiscoveryClient;
public ServicesEagerLoadSmartLifecycle(ApplicationContext applicationContext, PolarisDiscoveryClient polarisDiscoveryClient, public ServicesEagerLoadSmartLifecycle(PolarisDiscoveryClient polarisDiscoveryClient,
PolarisReactiveDiscoveryClient polarisReactiveDiscoveryClient) { PolarisReactiveDiscoveryClient polarisReactiveDiscoveryClient) {
this.applicationContext = applicationContext;
this.polarisDiscoveryClient = polarisDiscoveryClient; this.polarisDiscoveryClient = polarisDiscoveryClient;
this.polarisReactiveDiscoveryClient = polarisReactiveDiscoveryClient; this.polarisReactiveDiscoveryClient = polarisReactiveDiscoveryClient;
} }
@ -53,7 +49,7 @@ public class ServicesEagerLoadSmartLifecycle implements SmartLifecycle {
LOG.info("eager-load got services: {}", servicesList); LOG.info("eager-load got services: {}", servicesList);
} }
else if (polarisReactiveDiscoveryClient != null) { else if (polarisReactiveDiscoveryClient != null) {
polarisReactiveDiscoveryClient.getServices().subscribe(services -> { polarisReactiveDiscoveryClient.getServices().collectList().subscribe(services -> {
LOG.info("eager-load got services: {}", services); LOG.info("eager-load got services: {}", services);
}); });
} }

Loading…
Cancel
Save