tristaZero commented on a change in pull request #9796:
URL: https://github.com/apache/shardingsphere/pull/9796#discussion_r601097466



##########
File path: 
shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/registry/RegistryCenter.java
##########
@@ -451,6 +458,17 @@ public synchronized void renew(final 
RuleConfigurationCachedEvent event) {
     @Subscribe
     public synchronized void renew(final CreateUserEvent event) {
         persistAuthentication(event.getUsers(), true);
+        persistChangedAuthentication(event.getUsers(), true);
+    }
+    
+    /**
+     * User with changed privilege cached event.
+     *
+     * @param event grant event
+     */
+    @Subscribe
+    public synchronized void renew(final GrantEvent event) {
+        persistChangedAuthentication(event.getUsers(), true);

Review comment:
       `persistChangedAuthentication` -> `persistChangedPrivilege`

##########
File path: 
shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/registry/RegistryCenter.java
##########
@@ -190,6 +191,12 @@ private void persistAuthentication(final 
Collection<ShardingSphereUser> users, f
                     YamlEngine.marshal(new 
UserRuleYamlSwapper().swapToYamlConfiguration(users)));
         }
     }
+    
+    private void persistChangedAuthentication(final 
Collection<ShardingSphereUser> users, final boolean isOverwrite) {
+        if (!users.isEmpty() && isOverwrite) {

Review comment:
       `isOverwrite` is needed?

##########
File path: 
shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/registry/RegistryCenter.java
##########
@@ -451,6 +458,17 @@ public synchronized void renew(final 
RuleConfigurationCachedEvent event) {
     @Subscribe
     public synchronized void renew(final CreateUserEvent event) {
         persistAuthentication(event.getUsers(), true);
+        persistChangedAuthentication(event.getUsers(), true);

Review comment:
       It is possible to remove `persistChangedAuthentication()` ?

##########
File path: 
shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/registry/listener/RegistryListenerManager.java
##########
@@ -59,5 +62,6 @@ public void initListeners() {
         metaDataListener.watch();
         propertiesChangedListener.watch(Type.UPDATED);
         authenticationChangedListener.watch(Type.UPDATED);
+        authenticationNodesChangedListener.watch(Type.UPDATED);

Review comment:
       `authenticationNodesChangedListener` -> `privilegeNodesChangedListener`

##########
File path: 
shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/registry/RegistryCenter.java
##########
@@ -190,6 +191,12 @@ private void persistAuthentication(final 
Collection<ShardingSphereUser> users, f
                     YamlEngine.marshal(new 
UserRuleYamlSwapper().swapToYamlConfiguration(users)));
         }
     }
+    
+    private void persistChangedAuthentication(final 
Collection<ShardingSphereUser> users, final boolean isOverwrite) {

Review comment:
       persistChangedPrivilege




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to