feat: support config event and monitor address list.

pull/1670/head
fishtailfu 1 month ago
parent a5b9ae9403
commit 3f839fde3b

@ -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)

@ -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<String> 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<String> getAddress() {
return address;
}
public void setAddress(String address) {
public void setAddress(List<String> address) {
this.address = address;
}

@ -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");

@ -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");

@ -51,7 +51,7 @@ public class PolarisStatProperties {
* PushGateway address.
*/
@Value("${spring.cloud.polaris.stat.pushgateway.address:}")
private String pushGatewayAddress;
private List<String> pushGatewayAddress;
/**
* PushGateway namespace.
@ -107,11 +107,11 @@ public class PolarisStatProperties {
this.pushGatewayEnabled = pushGatewayEnabled;
}
public String getPushGatewayAddress() {
public List<String> getPushGatewayAddress() {
return pushGatewayAddress;
}
public void setPushGatewayAddress(String pushGatewayAddress) {
public void setPushGatewayAddress(List<String> pushGatewayAddress) {
this.pushGatewayAddress = pushGatewayAddress;
}

@ -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<String> 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);

Loading…
Cancel
Save