feat:support ipv6. (#1592)

pull/1593/head
Haotian Zhang 3 months ago committed by GitHub
parent 96221289b8
commit 5ae18a62d5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -4,3 +4,4 @@
- [fix: add gateway context config example.](https://github.com/Tencent/spring-cloud-tencent/pull/1562)
- [feat:support config empty protection.](https://github.com/Tencent/spring-cloud-tencent/pull/1581)
- [feat:support dynamic multi-discovery.](https://github.com/Tencent/spring-cloud-tencent/pull/1591)
- [feat:support ipv6.](https://github.com/Tencent/spring-cloud-tencent/pull/1592)

@ -112,6 +112,11 @@ public class PolarisDiscoveryProperties {
@Value("${spring.cloud.polaris.discovery.zero-protection.is-need-test-connectivity:false}")
private boolean zeroProtectionNeedTestConnectivity = false;
/**
* if prefer ipv6.
*/
private Boolean preferIpv6 = false;
public String getInstanceId() {
return instanceId;
}
@ -219,6 +224,14 @@ public class PolarisDiscoveryProperties {
this.zeroProtectionNeedTestConnectivity = zeroProtectionNeedTestConnectivity;
}
public Boolean getPreferIpv6() {
return preferIpv6;
}
public void setPreferIpv6(Boolean preferIpv6) {
this.preferIpv6 = preferIpv6;
}
public Boolean getEnabled() {
return enabled;
}
@ -256,6 +269,7 @@ public class PolarisDiscoveryProperties {
", serviceListRefreshInterval=" + serviceListRefreshInterval +
", zeroProtectionEnabled=" + zeroProtectionEnabled +
", zeroProtectionNeedTestConnectivity=" + zeroProtectionNeedTestConnectivity +
", preferIpv6=" + preferIpv6 +
'}';
}
}

@ -59,6 +59,7 @@ public class PolarisDiscoveryHandler {
getHealthyInstancesRequest.setNamespace(namespace);
getHealthyInstancesRequest.setService(service);
getHealthyInstancesRequest.setIncludeCircuitBreakInstances(false);
getHealthyInstancesRequest.setPreferIpv6(polarisDiscoveryProperties.getPreferIpv6());
return polarisConsumer.getHealthyInstances(getHealthyInstancesRequest);
}

@ -78,6 +78,12 @@
"defaultValue": false,
"description": "Zero protection test connectivity switch. Default: false."
},
{
"name": "spring.cloud.polaris.discovery.prefer-ipv6",
"type": "java.lang.Boolean",
"defaultValue": false,
"description": "if prefer ipv6. Default: false."
},
{
"name": "spring.cloud.polaris.discovery.eager-load.enabled",
"type": "java.lang.Boolean",

@ -102,6 +102,7 @@ public class PolarisDiscoveryPropertiesTest {
+ ", healthCheckUrl='/health'"
+ ", serviceListRefreshInterval=1000"
+ ", zeroProtectionEnabled=false"
+ ", zeroProtectionNeedTestConnectivity=false}");
+ ", zeroProtectionNeedTestConnectivity=false"
+ ", preferIpv6=false}");
}
}

@ -74,6 +74,11 @@ public final class TsfCoreEnvironmentPostProcessor implements EnvironmentPostPro
defaultProperties.put("spring.cloud.polaris.lossless.enabled", environment.getProperty("spring.cloud.polaris.lossless.enabled", "true"));
}
String tsfPreferIpv6 = environment.getProperty("tsf_prefer_ipv6");
if (StringUtils.isNotBlank(tsfPreferIpv6)) {
defaultProperties.put("spring.cloud.polaris.discovery.prefer-ipv6", tsfPreferIpv6);
}
if (TsfContextUtils.isTsfConsulEnabled(environment)) {
// tsf_consul_ip
String tsfConsulIp = environment.getProperty("tsf_consul_ip");

Loading…
Cancel
Save