mirror of
https://gitee.com/mirrors/Spring-Cloud-Alibaba.git
synced 2021-06-26 13:25:11 +08:00
[enhance issue #1478 ]支持注册非活动节点
This commit is contained in:
parent
213bf2a912
commit
0a89ad61e1
@ -33,6 +33,7 @@ spring:
|
||||
enabled: true
|
||||
register-enabled: true
|
||||
server-addr: 127.0.0.1:8848
|
||||
ephemeral: false
|
||||
|
||||
|
||||
---
|
||||
|
@ -204,6 +204,11 @@ public class NacosDiscoveryProperties {
|
||||
*/
|
||||
private boolean instanceEnabled = true;
|
||||
|
||||
/**
|
||||
* If instance is ephemeral.The default value is true.
|
||||
*/
|
||||
private boolean ephemeral = true;
|
||||
|
||||
@Autowired
|
||||
private InetUtils inetUtils;
|
||||
|
||||
@ -461,6 +466,14 @@ public class NacosDiscoveryProperties {
|
||||
this.instanceEnabled = instanceEnabled;
|
||||
}
|
||||
|
||||
public boolean isEphemeral() {
|
||||
return ephemeral;
|
||||
}
|
||||
|
||||
public void setEphemeral(boolean ephemeral) {
|
||||
this.ephemeral = ephemeral;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "NacosDiscoveryProperties{" + "serverAddr='" + serverAddr + '\''
|
||||
|
@ -92,6 +92,7 @@ public class NacosServiceDiscovery {
|
||||
metadata.put("nacos.weight", instance.getWeight() + "");
|
||||
metadata.put("nacos.healthy", instance.isHealthy() + "");
|
||||
metadata.put("nacos.cluster", instance.getClusterName() + "");
|
||||
metadata.put("nacos.ephemeral",String.valueOf(instance.isEphemeral()));
|
||||
metadata.putAll(instance.getMetadata());
|
||||
nacosServiceInstance.setMetadata(metadata);
|
||||
|
||||
|
@ -161,7 +161,7 @@ public class NacosServiceRegistry implements ServiceRegistry<Registration> {
|
||||
instance.setClusterName(nacosDiscoveryProperties.getClusterName());
|
||||
instance.setEnabled(nacosDiscoveryProperties.isInstanceEnabled());
|
||||
instance.setMetadata(registration.getMetadata());
|
||||
|
||||
instance.setEphemeral(nacosDiscoveryProperties.isEphemeral());
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,12 @@
|
||||
"defaultValue": true,
|
||||
"description": "If instance is enabled to accept request. The default value is true."
|
||||
},
|
||||
{
|
||||
"name": "spring.cloud.nacos.discovery.ephemeral",
|
||||
"type": "java.lang.Boolean",
|
||||
"defaultValue": true,
|
||||
"description": "If instance is ephemeral.The default value is true."
|
||||
},
|
||||
{
|
||||
"name": "spring.cloud.nacos.discovery.namingLoadCacheAtStart",
|
||||
"type": "java.lang.Boolean",
|
||||
|
Loading…
x
Reference in New Issue
Block a user