diff --git a/CHANGELOG.md b/CHANGELOG.md index 87b6983b1..e3707be99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,3 +11,4 @@ - [feat:support traffic mirroring.](https://github.com/Tencent/spring-cloud-tencent/pull/1647) - [feat: support custom quickstart circuitbreak delay time.](https://github.com/Tencent/spring-cloud-tencent/pull/1666) - [feat: add delay interface in tsf-example.](https://github.com/Tencent/spring-cloud-tencent/pull/1668) +- [feat: support config event and monitor address list.](https://github.com/Tencent/spring-cloud-tencent/pull/1670) diff --git a/spring-cloud-tencent-polaris-context/src/main/java/com/tencent/cloud/polaris/context/event/PushGatewayEventReporterProperties.java b/spring-cloud-tencent-polaris-context/src/main/java/com/tencent/cloud/polaris/context/event/PushGatewayEventReporterProperties.java index 2ccfed012..bbc429530 100644 --- a/spring-cloud-tencent-polaris-context/src/main/java/com/tencent/cloud/polaris/context/event/PushGatewayEventReporterProperties.java +++ b/spring-cloud-tencent-polaris-context/src/main/java/com/tencent/cloud/polaris/context/event/PushGatewayEventReporterProperties.java @@ -17,6 +17,8 @@ package com.tencent.cloud.polaris.context.event; +import java.util.List; + import org.springframework.boot.context.properties.ConfigurationProperties; /** @@ -35,7 +37,7 @@ public class PushGatewayEventReporterProperties { /** * Address of pushgateway. For example: 1.2.3.4:9091. */ - private String address; + private List address; /** * Queue size for push gateway event queue. Default is 1000. @@ -65,11 +67,11 @@ public class PushGatewayEventReporterProperties { this.enabled = enabled; } - public String getAddress() { + public List getAddress() { return address; } - public void setAddress(String address) { + public void setAddress(List address) { this.address = address; } diff --git a/spring-cloud-tencent-polaris-context/src/test/java/com/tencent/cloud/polaris/context/event/PushGatewayEventReporterConfigModifierTest.java b/spring-cloud-tencent-polaris-context/src/test/java/com/tencent/cloud/polaris/context/event/PushGatewayEventReporterConfigModifierTest.java index 0de0a2acc..8d7fd003a 100644 --- a/spring-cloud-tencent-polaris-context/src/test/java/com/tencent/cloud/polaris/context/event/PushGatewayEventReporterConfigModifierTest.java +++ b/spring-cloud-tencent-polaris-context/src/test/java/com/tencent/cloud/polaris/context/event/PushGatewayEventReporterConfigModifierTest.java @@ -39,7 +39,7 @@ public class PushGatewayEventReporterConfigModifierTest { private final ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner() .withConfiguration(AutoConfigurations.of(PolarisContextAutoConfiguration.class)) .withPropertyValues("spring.cloud.polaris.event.pushgateway.enabled=true") - .withPropertyValues("spring.cloud.polaris.event.pushgateway.address=1.2.3.4:9091") + .withPropertyValues("spring.cloud.polaris.event.pushgateway.address=1.2.3.4:9091,1.2.3.5:9091") .withPropertyValues("spring.cloud.polaris.event.pushgateway.eventQueueSize=123") .withPropertyValues("spring.cloud.polaris.event.pushgateway.maxBatchSize=456") .withPropertyValues("spring.cloud.polaris.event.pushgateway.namespace=test-namespace") @@ -58,7 +58,8 @@ public class PushGatewayEventReporterConfigModifierTest { getConfig().getGlobal().getEventReporter() .getPluginConfig(DefaultPlugins.PUSH_GATEWAY_EVENT_REPORTER_TYPE, PushGatewayEventReporterConfig.class); assertThat(config.isEnable()).isTrue(); - assertThat(config.getAddress()).isEqualTo("1.2.3.4:9091"); + assertThat(config.getAddress().get(0)).isEqualTo("1.2.3.4:9091"); + assertThat(config.getAddress().get(1)).isEqualTo("1.2.3.5:9091"); assertThat(config.getEventQueueSize()).isEqualTo(123); assertThat(config.getMaxBatchSize()).isEqualTo(456); assertThat(config.getNamespace()).isEqualTo("test-namespace"); diff --git a/spring-cloud-tencent-polaris-context/src/test/java/com/tencent/cloud/polaris/context/event/PushGatewayEventReporterPropertiesTest.java b/spring-cloud-tencent-polaris-context/src/test/java/com/tencent/cloud/polaris/context/event/PushGatewayEventReporterPropertiesTest.java index c6a2a747d..473f6e949 100644 --- a/spring-cloud-tencent-polaris-context/src/test/java/com/tencent/cloud/polaris/context/event/PushGatewayEventReporterPropertiesTest.java +++ b/spring-cloud-tencent-polaris-context/src/test/java/com/tencent/cloud/polaris/context/event/PushGatewayEventReporterPropertiesTest.java @@ -37,7 +37,7 @@ public class PushGatewayEventReporterPropertiesTest { private final ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner() .withConfiguration(AutoConfigurations.of(PolarisContextAutoConfiguration.class)) .withPropertyValues("spring.cloud.polaris.event.pushgateway.enabled=true") - .withPropertyValues("spring.cloud.polaris.event.pushgateway.address=1.2.3.4:9091") + .withPropertyValues("spring.cloud.polaris.event.pushgateway.address=1.2.3.4:9091,1.2.3.5:9091") .withPropertyValues("spring.cloud.polaris.event.pushgateway.eventQueueSize=123") .withPropertyValues("spring.cloud.polaris.event.pushgateway.maxBatchSize=456") .withPropertyValues("spring.cloud.polaris.event.pushgateway.namespace=test-namespace") @@ -53,7 +53,8 @@ public class PushGatewayEventReporterPropertiesTest { this.applicationContextRunner.run(context -> { PushGatewayEventReporterProperties properties = context.getBean(PushGatewayEventReporterProperties.class); assertThat(properties.isEnabled()).isTrue(); - assertThat(properties.getAddress()).isEqualTo("1.2.3.4:9091"); + assertThat(properties.getAddress().get(0)).isEqualTo("1.2.3.4:9091"); + assertThat(properties.getAddress().get(1)).isEqualTo("1.2.3.5:9091"); assertThat(properties.getEventQueueSize()).isEqualTo(123); assertThat(properties.getMaxBatchSize()).isEqualTo(456); assertThat(properties.getNamespace()).isEqualTo("test-namespace"); diff --git a/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/stat/config/PolarisStatProperties.java b/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/stat/config/PolarisStatProperties.java index b5d17b4a2..07eba89a7 100644 --- a/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/stat/config/PolarisStatProperties.java +++ b/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/stat/config/PolarisStatProperties.java @@ -51,7 +51,7 @@ public class PolarisStatProperties { * PushGateway address. */ @Value("${spring.cloud.polaris.stat.pushgateway.address:}") - private String pushGatewayAddress; + private List pushGatewayAddress; /** * PushGateway namespace. @@ -107,11 +107,11 @@ public class PolarisStatProperties { this.pushGatewayEnabled = pushGatewayEnabled; } - public String getPushGatewayAddress() { + public List getPushGatewayAddress() { return pushGatewayAddress; } - public void setPushGatewayAddress(String pushGatewayAddress) { + public void setPushGatewayAddress(List pushGatewayAddress) { this.pushGatewayAddress = pushGatewayAddress; } diff --git a/spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/stat/config/PolarisStatPropertiesTest.java b/spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/stat/config/PolarisStatPropertiesTest.java index b193e171d..cfe09e8f9 100644 --- a/spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/stat/config/PolarisStatPropertiesTest.java +++ b/spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/stat/config/PolarisStatPropertiesTest.java @@ -17,6 +17,8 @@ package com.tencent.cloud.rpc.enhancement.stat.config; +import java.util.List; + import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.AutoConfigurations; @@ -37,7 +39,7 @@ public class PolarisStatPropertiesTest { .withPropertyValues("spring.cloud.polaris.stat.enabled=true") .withPropertyValues("spring.cloud.polaris.stat.path=/xxx") .withPropertyValues("spring.cloud.polaris.stat.pushgateway.enabled=true") - .withPropertyValues("spring.cloud.polaris.stat.pushgateway.address=127.0.0.1:9091") + .withPropertyValues("spring.cloud.polaris.stat.pushgateway.address=127.0.0.1:9091,127.0.0.1:9092") .withPropertyValues("spring.cloud.polaris.stat.pushgateway.namespace=test-namespace") .withPropertyValues("spring.cloud.polaris.stat.pushgateway.service=test-service") .withPropertyValues("spring.cloud.polaris.stat.pushgateway.push-interval=1000") @@ -52,7 +54,8 @@ public class PolarisStatPropertiesTest { assertThat(polarisStatProperties.isEnabled()).isTrue(); assertThat(polarisStatProperties.getPath()).isEqualTo("/xxx"); assertThat(polarisStatProperties.isPushGatewayEnabled()).isTrue(); - assertThat(polarisStatProperties.getPushGatewayAddress()).isEqualTo("127.0.0.1:9091"); + assertThat(polarisStatProperties.getPushGatewayAddress().get(0)).isEqualTo("127.0.0.1:9091"); + assertThat(polarisStatProperties.getPushGatewayAddress().get(1)).isEqualTo("127.0.0.1:9092"); assertThat(polarisStatProperties.getStatNamespace()).isEqualTo("test-namespace"); assertThat(polarisStatProperties.getStatService()).isEqualTo("test-service"); assertThat(polarisStatProperties.getPushGatewayPushInterval().toString()).isEqualTo("1000"); @@ -68,8 +71,10 @@ public class PolarisStatPropertiesTest { assertThat(polarisStatProperties.isPushGatewayEnabled()).isTrue(); // PushGatewayAddress - polarisStatProperties.setPushGatewayAddress("127.0.0.1:9091"); - assertThat(polarisStatProperties.getPushGatewayAddress()).isEqualTo("127.0.0.1:9091"); + List pushGatewayAddress = List.of("127.0.0.1:9091", "127.0.0.1:9092"); + polarisStatProperties.setPushGatewayAddress(pushGatewayAddress); + assertThat(polarisStatProperties.getPushGatewayAddress().get(0)).isEqualTo("127.0.0.1:9091"); + assertThat(polarisStatProperties.getPushGatewayAddress().get(1)).isEqualTo("127.0.0.1:9092"); // PushGatewayPushInterval polarisStatProperties.setPushGatewayPushInterval(1000L);