Skip to content

Commit

Permalink
feat(sermant-springboot-registry): 添加 Nacos 注册中心支持
Browse files Browse the repository at this point in the history
- 新增 NacosRegisterConfig 类用于配置 Nacos 相关参数
- 实现 NacosDiscoveryClient 类以支持 Nacos服务发现和注册
- 添加 NacosServiceManager 类用于管理 Nacos 服务
- 实现 NacosInstanceListenable 类以监听 Nacos 实例变化
- 新增 NacosWeightRandomRule 类用于 Nacos 权重随机负载均衡
- 更新配置文件和资源文件以支持 Nacos

Signed-off-by: xiaozhao <[email protected]>
  • Loading branch information
xiaozhao committed Nov 30, 2024
1 parent 127425c commit 6433cb0
Show file tree
Hide file tree
Showing 28 changed files with 1,481 additions and 30 deletions.
20 changes: 20 additions & 0 deletions sermant-plugins/sermant-springboot-registry/config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ sermant.springboot.registry:
realmName: www.domain.com
# Whether to enable traffic statistics, after it is enabled, the traffic entering the plug-in will be printed every time
enableRequestCount: false
# The type of the registry center, currently supports NACOS and ZOOKEEPER
registryCenterType: ZOOKEEPER

sermant.springboot.registry.lb:
# The load balancer type currently supports RoundRobin、Random、WeightedResponseTime、
Expand All @@ -28,3 +30,21 @@ sermant.springboot.registry.lb:
# For retry scenarios, for {@link java.util.concurrent.TimeoutException}, whether you need to retry, which is enabled
# by default, and this timeout is mostly used in asynchronous scenarios, such as Future, MinimalHttpAsyncClient
enableTimeoutExRetry: true

nacos.config:
# Whether to enable authentication
enableAuth: false
# nacos verifies accounts
username: ""
# nacos verifies password need encrypts
password: ""
# Specify the AES privateKey that encrypts and decrypts the password
privateKey: ""
# Namespace, the nacos configuration creates the id value of the namespace
namespace: ""
# Service instance weight value
weight: 1
# Cluster name
clusterName: DEFAULT
# Whether it is a temporary node. The value can be true or false
ephemeral: true
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ public class DiscoveryPluginConfig implements PluginConfig {
*/
private boolean enableRegistry = true;

/**
* Registry type, currently supports NACOS and ZOOKEEPER;
*/
private RegisterType registerType = RegisterType.ZOOKEEPER;

public boolean isEnableRegistry() {
return enableRegistry;
}
Expand All @@ -65,4 +70,12 @@ public boolean isEnableRequestCount() {
public void setEnableRequestCount(boolean enableRequestCount) {
this.enableRequestCount = enableRequestCount;
}

public RegisterType getRegisterType() {
return registerType;
}

public void setRegisterType(RegisterType registerType) {
this.registerType = registerType;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,6 @@ public class LbConfig implements PluginConfig {
*/
private String registryAddress = "127.0.0.1:2181";

/**
* Registry type, currently only ZK is supported
*/
private String registryCenterType = "Zookeeper";

/**
* When it is enabled, if other registries are the same as the registries of this plugin and are registered to the
* registry at the same time, the registries that are not registered by the plugin will be automatically excluded
Expand Down Expand Up @@ -309,14 +304,6 @@ public void setOnlyCurRegisterInstances(boolean onlyCurRegisterInstances) {
this.onlyCurRegisterInstances = onlyCurRegisterInstances;
}

public String getRegistryCenterType() {
return registryCenterType;
}

public void setRegistryCenterType(String registryCenterType) {
this.registryCenterType = registryCenterType;
}

public String getZkServerVersion() {
return zkServerVersion;
}
Expand Down
Loading

0 comments on commit 6433cb0

Please sign in to comment.