liubao68 commented on code in PR #4670:
URL: 
https://github.com/apache/servicecomb-java-chassis/pull/4670#discussion_r1910060332


##########
service-registry/registry-nacos/src/main/java/org/apache/servicecomb/registry/nacos/NacosRegistration.java:
##########
@@ -132,9 +132,20 @@ public NacosRegistrationInstance getMicroserviceInstance() 
{
 
   @Override
   public boolean updateMicroserviceInstanceStatus(MicroserviceInstanceStatus 
status) {
-    // Do not support Nacos update status now. Because update status will fail
-    // due to some unknown reasons(Maybe different constrains in register and 
maintain api).
-    return true;
+    try {
+      if (MicroserviceInstanceStatus.DOWN == status) {
+        instance.getMetadata().put(NacosConst.NACOS_STATUS, 
MicroserviceInstanceStatus.DOWN.name());
+        
namingService.deregisterInstance(nacosRegistrationInstance.getServiceName(),
+            nacosRegistrationInstance.getApplication(), instance);
+      } else {
+        instance.getMetadata().put(NacosConst.NACOS_STATUS, status.name());
+        
namingService.registerInstance(nacosRegistrationInstance.getServiceName(),
+            nacosRegistrationInstance.getApplication(), instance);
+      }
+      return true;
+    } catch (Exception e) {
+      throw new RuntimeException(e);
+    }

Review Comment:
   It's better only set status, do not deregister instance. 



-- 
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.

To unsubscribe, e-mail: [email protected]

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

Reply via email to