mirror of
https://gitee.com/mirrors/Spring-Cloud-Alibaba.git
synced 2021-06-26 13:25:11 +08:00
merge endpoint and endpoint configuration
This commit is contained in:
@@ -59,12 +59,6 @@ public class NacosDiscoveryProperties {
|
||||
*/
|
||||
private String endpoint;
|
||||
|
||||
/**
|
||||
* the domain port of a service, through which the server address can be dynamically
|
||||
* obtained.
|
||||
*/
|
||||
private String endpointPort;
|
||||
|
||||
/**
|
||||
* namespace, separation registry of different environments.
|
||||
*/
|
||||
@@ -341,26 +335,18 @@ public class NacosDiscoveryProperties {
|
||||
this.watchDelay = watchDelay;
|
||||
}
|
||||
|
||||
public String getEndpointPort() {
|
||||
return endpointPort;
|
||||
}
|
||||
|
||||
public void setEndpointPort(String endpointPort) {
|
||||
this.endpointPort = endpointPort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "NacosDiscoveryProperties{" + "serverAddr='" + serverAddr + '\''
|
||||
+ ", endpoint='" + endpoint + '\'' + ", endpointPort='" + endpointPort
|
||||
+ '\'' + ", namespace='" + namespace + '\'' + ", watchDelay=" + watchDelay
|
||||
+ ", logName='" + logName + '\'' + ", service='" + service + '\''
|
||||
+ ", weight=" + weight + ", clusterName='" + clusterName + '\''
|
||||
+ ", namingLoadCacheAtStart='" + namingLoadCacheAtStart + '\''
|
||||
+ ", metadata=" + metadata + ", registerEnabled=" + registerEnabled
|
||||
+ ", ip='" + ip + '\'' + ", networkInterface='" + networkInterface + '\''
|
||||
+ ", port=" + port + ", secure=" + secure + ", accessKey='" + accessKey
|
||||
+ '\'' + ", secretKey='" + secretKey + '\'' + '}';
|
||||
+ ", endpoint='" + endpoint + '\'' + ", namespace='" + namespace + '\''
|
||||
+ ", watchDelay=" + watchDelay + ", logName='" + logName + '\''
|
||||
+ ", service='" + service + '\'' + ", weight=" + weight
|
||||
+ ", clusterName='" + clusterName + '\'' + ", namingLoadCacheAtStart='"
|
||||
+ namingLoadCacheAtStart + '\'' + ", metadata=" + metadata
|
||||
+ ", registerEnabled=" + registerEnabled + ", ip='" + ip + '\''
|
||||
+ ", networkInterface='" + networkInterface + '\'' + ", port=" + port
|
||||
+ ", secure=" + secure + ", accessKey='" + accessKey + '\''
|
||||
+ ", secretKey='" + secretKey + '\'' + '}';
|
||||
}
|
||||
|
||||
public void overrideFromEnv(Environment env) {
|
||||
@@ -393,10 +379,6 @@ public class NacosDiscoveryProperties {
|
||||
this.setEndpoint(
|
||||
env.resolvePlaceholders("${spring.cloud.nacos.discovery.endpoint:}"));
|
||||
}
|
||||
if (StringUtils.isEmpty(this.getEndpointPort())) {
|
||||
this.setEndpointPort(env.resolvePlaceholders(
|
||||
"${spring.cloud.nacos.discovery.endpoint-port:}"));
|
||||
}
|
||||
}
|
||||
|
||||
public NamingService namingServiceInstance() {
|
||||
@@ -409,8 +391,16 @@ public class NacosDiscoveryProperties {
|
||||
properties.put(SERVER_ADDR, serverAddr);
|
||||
properties.put(NAMESPACE, namespace);
|
||||
properties.put(UtilAndComs.NACOS_NAMING_LOG_NAME, logName);
|
||||
properties.put(ENDPOINT, endpoint);
|
||||
properties.put(ENDPOINT_PORT, endpointPort);
|
||||
|
||||
if (endpoint.contains(":")) {
|
||||
int index = endpoint.indexOf(":");
|
||||
properties.put(ENDPOINT, endpoint.substring(0, index));
|
||||
properties.put(ENDPOINT_PORT, endpoint.substring(index + 1));
|
||||
}
|
||||
else {
|
||||
properties.put(ENDPOINT, endpoint);
|
||||
}
|
||||
|
||||
properties.put(ACCESS_KEY, accessKey);
|
||||
properties.put(SECRET_KEY, secretKey);
|
||||
properties.put(CLUSTER_NAME, clusterName);
|
||||
|
@@ -19,7 +19,6 @@ package org.springframework.cloud.alibaba.nacos.discovery;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.cloud.alibaba.nacos.ConditionalOnNacosDiscoveryEnabled;
|
||||
import org.springframework.cloud.alibaba.nacos.NacosDiscoveryProperties;
|
||||
|
@@ -48,7 +48,6 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
|
||||
"spring.application.name=myTestService1",
|
||||
"spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848",
|
||||
"spring.cloud.nacos.discovery.endpoint=test-endpoint",
|
||||
"spring.cloud.nacos.discovery.endpoint-port=8081",
|
||||
"spring.cloud.nacos.discovery.namespace=test-namespace",
|
||||
"spring.cloud.nacos.discovery.log-name=test-logName",
|
||||
"spring.cloud.nacos.discovery.weight=2",
|
||||
@@ -84,7 +83,6 @@ public class NacosAutoServiceRegistrationTests {
|
||||
|
||||
checkoutNacosDiscoveryServerAddr();
|
||||
checkoutNacosDiscoveryEndpoint();
|
||||
checkoutNacosDiscoveryEndpointPort();
|
||||
checkoutNacosDiscoveryNamespace();
|
||||
checkoutNacosDiscoveryLogName();
|
||||
checkoutNacosDiscoveryWeight();
|
||||
@@ -121,12 +119,6 @@ public class NacosAutoServiceRegistrationTests {
|
||||
|
||||
}
|
||||
|
||||
private void checkoutNacosDiscoveryEndpointPort() {
|
||||
assertEquals("NacosDiscoveryProperties endpoint port was wrong", "8081",
|
||||
properties.getEndpointPort());
|
||||
|
||||
}
|
||||
|
||||
private void checkoutNacosDiscoveryNamespace() {
|
||||
assertEquals("NacosDiscoveryProperties namespace was wrong", "test-namespace",
|
||||
properties.getNamespace());
|
||||
|
Reference in New Issue
Block a user