tzssangglass commented on pull request #6247:
URL: https://github.com/apache/apisix/pull/6247#issuecomment-1034469886


   hi @xianshun163 , I have another fix idea to discuss with you.
   
   Before adding a new service to services, we can do a de-duplication, we can 
add de_duplication function in 
https://github.com/apache/apisix/blob/06c51935aa207eef8ef75df24172e8656085c3ff/apisix/discovery/nacos/init.lua#L200-L203
   
   L202
   
   the code may like 
   
   ```lua
           local dup = de_duplication(services, namespace_id, group_name,
                   up.service_name, up.scheme)
           if dup then
               goto CONTINUE
           end
           if up.discovery_type == 'nacos' then
   ```
   
   we can compare new service and services in de_duplication function, such as:
   
   ```lua
   local function de_duplication(services, namespace_id, group_name, 
service_name, scheme)
       for _, service in ipairs(services) do
           if service.namespace_id == namespace_id and service.group_name == 
group_name
                   and service.service_name == service_name and service.scheme 
== scheme then
               return true
           end
       end
       return false
   end
   ```
   


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