Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimize: support the nacos application name property #5783

Merged
merged 4 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public class NacosRegistryServiceImpl implements RegistryService<EventListener>
private static final String REGISTRY_TYPE = "nacos";
private static final String REGISTRY_CLUSTER = "cluster";
private static final String PRO_APPLICATION_KEY = "application";
private static final String PRO_CLIENT_APPLICATION = "clientApplication";
private static final String PRO_GROUP_KEY = "group";
private static final String USER_NAME = "username";
private static final String PASSWORD = "password";
Expand Down Expand Up @@ -326,6 +327,10 @@ public static String getNacosSecretKey() {
return String.join(ConfigurationKeys.FILE_CONFIG_SPLIT_CHAR, ConfigurationKeys.FILE_ROOT_REGISTRY, REGISTRY_TYPE, SECRET_KEY);
}

public static String getClientApplication() {
return String.join(ConfigurationKeys.FILE_CONFIG_SPLIT_CHAR, ConfigurationKeys.FILE_ROOT_REGISTRY, REGISTRY_TYPE, PRO_CLIENT_APPLICATION);
}

private static String getNacosUrlPatternOfSLB() {
return String.join(ConfigurationKeys.FILE_CONFIG_SPLIT_CHAR, ConfigurationKeys.FILE_ROOT_REGISTRY, REGISTRY_TYPE, SLB_PATTERN);
}
Expand Down
1 change: 1 addition & 0 deletions script/client/spring/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ seata.registry.nacos.namespace=
seata.registry.nacos.username=
seata.registry.nacos.password=
seata.registry.nacos.contextPath=
seata.registry.nacos.clientApplication=${spring.application.name}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

client增加这个配置后,应该是不影响服务发现的吧,只是订阅者的一个身份登记?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

client增加这个配置后,应该是不影响服务发现的吧,只是订阅者的一个身份登记?

不影响,只是订阅者的一个身份登记

##if use MSE Nacos with auth, mutex with username/password attribute
#seata.registry.nacos.access-key=
#seata.registry.nacos.secret-key=
Expand Down
1 change: 1 addition & 0 deletions script/client/spring/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ seata:
username:
password:
context-path:
client-application: ${spring.application.name}
##if use MSE Nacos with auth, mutex with username/password attribute
#access-key:
#secret-key:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class RegistryNacosProperties {
private String application = "seata-server";
private String slbPattern;
private String contextPath;

private String clientApplication;
public String getServerAddr() {
return serverAddr;
}
Expand Down Expand Up @@ -135,4 +135,12 @@ public RegistryNacosProperties setContextPath(String contextPath) {
this.contextPath = contextPath;
return this;
}

public String getClientApplication() {
return clientApplication;
}

public void setClientApplication(String clientApplication) {
this.clientApplication = clientApplication;
}
}
1 change: 1 addition & 0 deletions server/src/main/resources/application.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ seata:
username:
password:
context-path:
client-application: ${spring.application.name}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个配置应该是只有client用吧,我理解错了

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个配置应该是只有client用吧,我理解错了

我修改一下,提交

##if use MSE Nacos with auth, mutex with username/password attribute
#access-key:
#secret-key:
Expand Down