Re: [PR] feat(nacos): add metadata filtering support to nacos discovery [apisix]

2025-12-16 Thread via GitHub


Baoyuantop commented on PR #12445:
URL: https://github.com/apache/apisix/pull/12445#issuecomment-3659684111

   Hi @beardnick, please check those comments


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



Re: [PR] feat(nacos): add metadata filtering support to nacos discovery [apisix]

2025-12-08 Thread via GitHub


nic-6443 commented on code in PR #12445:
URL: https://github.com/apache/apisix/pull/12445#discussion_r2601366980


##
apisix/discovery/nacos/init.lua:
##
@@ -54,6 +56,20 @@ local function get_key(namespace_id, group_name, 
service_name)
 return namespace_id .. '.' .. group_name .. '.' .. service_name
 end
 
+
+local function metadata_contains(node_metadata, route_metadata)

Review Comment:
   ```suggestion
   local function metadata_contains(node_metadata, required_metadata)
   ```



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



Re: [PR] feat(nacos): add metadata filtering support to nacos discovery [apisix]

2025-12-08 Thread via GitHub


nic-6443 commented on code in PR #12445:
URL: https://github.com/apache/apisix/pull/12445#discussion_r2601366437


##
apisix/discovery/nacos/init.lua:
##
@@ -315,10 +331,12 @@ local function fetch_full_registry(premature)
 local key = get_key(namespace_id, group_name, 
service_info.service_name)
 service_names[key] = true
 for _, host in ipairs(data.hosts) do
+assert(host.metadata == nil or type(host.metadata) == "table")

Review Comment:
   `assert` will directly cause the program to panic and should be replaced 
with an error log to record illegal data. The program needs to consider various 
exceptional situations.



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



Re: [PR] feat(nacos): add metadata filtering support to nacos discovery [apisix]

2025-11-26 Thread via GitHub


beardnick commented on PR #12445:
URL: https://github.com/apache/apisix/pull/12445#issuecomment-3580625252

   @SkyeYoung @bzp2010 @nic-6443 @Revolyssup @AlinsRan @membphis The failed 
tests appear to be unrelated to my PR. Could you continue reviewing it?


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



Re: [PR] feat(nacos): add metadata filtering support to nacos discovery [apisix]

2025-11-20 Thread via GitHub


beardnick commented on PR #12445:
URL: https://github.com/apache/apisix/pull/12445#issuecomment-3561418903

   > Hi @beardnick, could you merge the code from the main branch again to make 
CI pass?
   
   Done


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



Re: [PR] feat(nacos): add metadata filtering support to nacos discovery [apisix]

2025-11-20 Thread via GitHub


Baoyuantop commented on PR #12445:
URL: https://github.com/apache/apisix/pull/12445#issuecomment-3561100758

   Hi @beardnick, could you merge the code from the main branch again to make 
CI pass?


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



Re: [PR] feat(nacos): add metadata filtering support to nacos discovery [apisix]

2025-11-11 Thread via GitHub


beardnick commented on PR #12445:
URL: https://github.com/apache/apisix/pull/12445#issuecomment-3519394032

   @Baoyuantop @SkyeYoung The failed tests appear to be unrelated to my PR. 
Could you continue reviewing it?


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



Re: [PR] feat(nacos): add metadata filtering support to nacos discovery [apisix]

2025-11-06 Thread via GitHub


Baoyuantop commented on code in PR #12445:
URL: https://github.com/apache/apisix/pull/12445#discussion_r2501423447


##
t/core/schema_def.t:
##
@@ -255,64 +255,173 @@ passed
 
 === TEST 5: validate IPv6 address format in upstream nodes
 --- config
-location /t {

Review Comment:
   Why was this part changed?



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



Re: [PR] feat(nacos): add metadata filtering support to nacos discovery [apisix]

2025-11-06 Thread via GitHub


beardnick commented on PR #12445:
URL: https://github.com/apache/apisix/pull/12445#issuecomment-3496324049

   @Baoyuantop @SkyeYoung ping


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



Re: [PR] feat(nacos): add metadata filtering support to nacos discovery [apisix]

2025-10-27 Thread via GitHub


Baoyuantop commented on code in PR #12445:
URL: https://github.com/apache/apisix/pull/12445#discussion_r2467763335


##
apisix/discovery/nacos/init.lua:
##
@@ -54,6 +56,25 @@ local function get_key(namespace_id, group_name, 
service_name)
 return namespace_id .. '.' .. group_name .. '.' .. service_name
 end
 
+
+local function metadata_contains(host_metadata, route_metadata)

Review Comment:
   host_metadata and node.metadata are mixed, it is recommended to unify them 
as node_metadata



##
apisix/discovery/nacos/init.lua:
##
@@ -54,6 +56,25 @@ local function get_key(namespace_id, group_name, 
service_name)
 return namespace_id .. '.' .. group_name .. '.' .. service_name
 end
 
+
+local function metadata_contains(host_metadata, route_metadata)
+if not host_metadata or not next(host_metadata) then
+return false
+end
+
+for k, v in pairs(route_metadata) do
+if type(v) ~= "string" then

Review Comment:
   Can we handle these checks at schema level?



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



Re: [PR] feat(nacos): add metadata filtering support to nacos discovery [apisix]

2025-09-13 Thread via GitHub


Baoyuantop commented on code in PR #12445:
URL: https://github.com/apache/apisix/pull/12445#discussion_r2331934894


##
docs/en/latest/discovery/nacos.md:
##
@@ -278,3 +279,52 @@ The formatted response as below:
   }
 }
 ```
+
+ Metadata filtering
+
+APISIX supports filtering service instances based on metadata. When a route is 
configured with metadata conditions, only service instances whose metadata 
contains all the key-value pairs specified in the route's `metadata` 
configuration will be selected. The metadata values in the route configuration 
are arrays, and a service instance matches if its metadata value equals any 
value in the corresponding array.
+
+Example: If a service instance has metadata `{lane: "a", env: "prod", version: 
"1.0"}`, it will match routes configured with metadata `{lane: ["a"]}` or 
`{lane: ["a"], env: ["prod"]}`, but not routes configured with `{lane: ["b"]}` 
or `{lane: ["a"], region: ["us"]}`.
+
+Example of routing a request with metadata filtering:
+
+```shell
+$ curl http://127.0.0.1:9180/apisix/admin/routes/5 -H "X-API-KEY: $admin_key" 
-X PUT -i -d '
+{
+"uri": "/nacosWithMetadata/*",
+"upstream": {
+"service_name": "APISIX-NACOS",
+"type": "roundrobin",
+"discovery_type": "nacos",
+"discovery_args": {
+  "metadata": {
+"version": ["v1"]

Review Comment:
   Hi @beardnick, please take a look.



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



Re: [PR] feat(nacos): add metadata filtering support to nacos discovery [apisix]

2025-09-04 Thread via GitHub


Baoyuantop commented on code in PR #12445:
URL: https://github.com/apache/apisix/pull/12445#discussion_r2321118197


##
docs/en/latest/discovery/nacos.md:
##
@@ -278,3 +279,52 @@ The formatted response as below:
   }
 }
 ```
+
+ Metadata filtering
+
+APISIX supports filtering service instances based on metadata. When a route is 
configured with metadata conditions, only service instances whose metadata 
contains all the key-value pairs specified in the route's `metadata` 
configuration will be selected. The metadata values in the route configuration 
are arrays, and a service instance matches if its metadata value equals any 
value in the corresponding array.
+
+Example: If a service instance has metadata `{lane: "a", env: "prod", version: 
"1.0"}`, it will match routes configured with metadata `{lane: ["a"]}` or 
`{lane: ["a"], env: ["prod"]}`, but not routes configured with `{lane: ["b"]}` 
or `{lane: ["a"], region: ["us"]}`.
+
+Example of routing a request with metadata filtering:
+
+```shell
+$ curl http://127.0.0.1:9180/apisix/admin/routes/5 -H "X-API-KEY: $admin_key" 
-X PUT -i -d '
+{
+"uri": "/nacosWithMetadata/*",
+"upstream": {
+"service_name": "APISIX-NACOS",
+"type": "roundrobin",
+"discovery_type": "nacos",
+"discovery_args": {
+  "metadata": {
+"version": ["v1"]

Review Comment:
   After careful consideration, I still feel that using an array here will 
increase complexity, and there is no such requirement at present. Since the 
metadata data comes from nacos, I think we should keep it consistent with the 
metadata format of nacos and use a simple key:value pair.



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



Re: [PR] feat(nacos): add metadata filtering support to nacos discovery [apisix]

2025-08-21 Thread via GitHub


beardnick commented on PR #12445:
URL: https://github.com/apache/apisix/pull/12445#issuecomment-3209937479

   @SkyeYoung Please rerun the failed tests.


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



Re: [PR] feat(nacos): add metadata filtering support to nacos discovery [apisix]

2025-08-17 Thread via GitHub


SkyeYoung commented on code in PR #12445:
URL: https://github.com/apache/apisix/pull/12445#discussion_r2281094276


##
docs/en/latest/discovery/nacos.md:
##
@@ -278,3 +279,52 @@ The formatted response as below:
   }
 }
 ```
+
+ Metadata filtering
+
+APISIX supports filtering service instances based on metadata. When a route is 
configured with metadata conditions, only service instances whose metadata 
contains all the key-value pairs specified in the route's `metadata` 
configuration will be selected.
+
+Example: If a service instance has metadata `{lane: "a", env: "prod", version: 
"1.0"}`, it will match routes configured with metadata `{lane: "a"}` or `{lane: 
"a", env: "prod"}`, but not routes configured with `{lane: "b"}` or `{lane: 
"a", region: "us"}`.
+
+Example of routing a request with metadata filtering:
+
+```shell
+$ curl http://127.0.0.1:9180/apisix/admin/routes/5 -H "X-API-KEY: $admin_key" 
-X PUT -i -d '
+{
+"uri": "/nacosWithMetadata/*",
+"upstream": {
+"service_name": "APISIX-NACOS",
+"type": "roundrobin",
+"discovery_type": "nacos",
+"discovery_args": {
+  "metadata": {
+"version": "v1"
+  }
+}
+}
+}'
+```
+
+This route will only route traffic to service instances that have the metadata 
field `version` set to `v1`.
+
+For multiple metadata criteria:
+
+```shell
+$ curl http://127.0.0.1:9180/apisix/admin/routes/6 -H "X-API-KEY: $admin_key" 
-X PUT -i -d '
+{
+"uri": "/nacosWithMultipleMetadata/*",
+"upstream": {
+"service_name": "APISIX-NACOS",
+"type": "roundrobin",
+"discovery_type": "nacos",
+"discovery_args": {
+  "metadata": {
+"lane": "a",
+"env": "prod"
+  }
+}
+}
+}'
+```

Review Comment:
   These examples should also be updated according to the code.



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



Re: [PR] feat(nacos): add metadata filtering support to nacos discovery [apisix]

2025-08-17 Thread via GitHub


SkyeYoung commented on code in PR #12445:
URL: https://github.com/apache/apisix/pull/12445#discussion_r2281092685


##
docs/en/latest/discovery/nacos.md:
##
@@ -132,6 +132,7 @@ $ curl http://127.0.0.1:9180/apisix/admin/stream_routes/1 
-H "X-API-KEY: $admin_
 |  | -- | --- | --- | - | 
 |
 | namespace_id | string | optional| public |   | This parameter is 
used to specify the namespace of the corresponding service |
 | group_name   | string | optional| DEFAULT_GROUP   |   | This 
parameter is used to specify the group of the corresponding service |
+| metadata | object | optional| {}  |   | Filter service 
instances by metadata using containment matching |

Review Comment:
   It seems the default value isn't `{}` now, but is being filtered out 
directly. Please remove these characters.



##
docs/zh/latest/discovery/nacos.md:
##
@@ -132,6 +132,7 @@ $ curl http://127.0.0.1:9180/apisix/admin/stream_routes/1 
-H "X-API-KEY: $admin_
 |  | -- | --- | --- | - | 
 |
 | namespace_id | string | 可选| public |   | 服务所在的命名空间 |
 | group_name   | string | 可选| DEFAULT_GROUP   |   | 服务所在的组 |
+| metadata | object | 可选| {}  |   | 使用包含匹配方式根据元数据过滤服务实例 |

Review Comment:
   ditto



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



Re: [PR] feat(nacos): add metadata filtering support to nacos discovery [apisix]

2025-08-17 Thread via GitHub


SkyeYoung commented on code in PR #12445:
URL: https://github.com/apache/apisix/pull/12445#discussion_r2281089720


##
apisix/discovery/nacos/init.lua:
##
@@ -319,6 +347,7 @@ local function fetch_full_registry(premature)
 host = host.ip,
 port = host.port,
 weight = host.weight or default_weight,
+metadata = host.metadata,

Review Comment:
   Are you sure `metadata` is a `table`? Please assert.



##
apisix/schema_def.lua:
##
@@ -488,7 +488,17 @@ local upstream_schema = {
 description = "group name",
 type = "string",
 },
-}
+metadata = {
+description = "metadata for filtering service instances",
+type = "object",
+additionalProperties = {
+type = "array",
+items = {
+type = "string"
+}
+}

Review Comment:
   Should we ensure `uniqueItems=true`?



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



Re: [PR] feat(nacos): add metadata filtering support to nacos discovery [apisix]

2025-08-11 Thread via GitHub


beardnick commented on PR #12445:
URL: https://github.com/apache/apisix/pull/12445#issuecomment-3177451271

   > @beardnick Please fix the errors reported in the CI.
   The failed tests seem unrelated to my PR. Could you please rerun them?


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



Re: [PR] feat(nacos): add metadata filtering support to nacos discovery [apisix]

2025-08-10 Thread via GitHub


SkyeYoung commented on PR #12445:
URL: https://github.com/apache/apisix/pull/12445#issuecomment-3173440559

   @beardnick Please fix the errors reported in the CI.


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



Re: [PR] feat(nacos): add metadata filtering support to nacos discovery [apisix]

2025-08-07 Thread via GitHub


beardnick commented on PR #12445:
URL: https://github.com/apache/apisix/pull/12445#issuecomment-3166608365

   > @beardnick Are you planning to implement this in this PR, or in another 
one?
   > 
   > If you want to implement it in other PRs, then this PR is ready for review.
   
   In this PR.


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



Re: [PR] feat(nacos): add metadata filtering support to nacos discovery [apisix]

2025-08-07 Thread via GitHub


SkyeYoung commented on PR #12445:
URL: https://github.com/apache/apisix/pull/12445#issuecomment-3166287675

   @beardnick Are you planning to implement this in this PR, or in another one?
   
   If you want to implement it in other PRs, then this PR is ready for review.


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



Re: [PR] feat(nacos): add metadata filtering support to nacos discovery [apisix]

2025-08-05 Thread via GitHub


beardnick commented on PR #12445:
URL: https://github.com/apache/apisix/pull/12445#issuecomment-3157229362

   > After checking #12392 and #12464, I have a question:
   > 
   > I haven't seen any discussions that should be implemented as single-value 
matching or multi-value matching?
   > 
   > #12464 Propose:
   > 
   > > Currently, someone in Nacos is also implementing the same function 
#12392 #12445, but only supports single value matching. However, we hope to 
support multi-value matching.
   > > This is because user requests often do not have any tags, so if we want 
to allow multiple instances with different metadata to provide services 
together, we must register a special metadata to group them, but this grouping 
cannot be changed dynamically.
   > 
   > I think it makes sense.
   > 
   > But I am not an expert in this field, so what do you think?
   
   Certainly, that sounds very reasonable. I’m happy to support multi-value 
matching.


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



Re: [PR] feat(nacos): add metadata filtering support to nacos discovery [apisix]

2025-08-03 Thread via GitHub


SkyeYoung commented on PR #12445:
URL: https://github.com/apache/apisix/pull/12445#issuecomment-3148878495

   @beardnick ping


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



Re: [PR] feat(nacos): add metadata filtering support to nacos discovery [apisix]

2025-07-30 Thread via GitHub


SkyeYoung commented on code in PR #12445:
URL: https://github.com/apache/apisix/pull/12445#discussion_r2244489111


##
apisix/discovery/nacos/init.lua:
##
@@ -54,6 +55,23 @@ local function get_key(namespace_id, group_name, 
service_name)
 return namespace_id .. '.' .. group_name .. '.' .. service_name
 end
 
+
+local function metadata_contains(host_metadata, route_metadata)
+if not route_metadata or not next(route_metadata) then
+return true
+end
+if not host_metadata or not next(host_metadata) then
+return false
+end
+
+for k, v in pairs(route_metadata) do
+if host_metadata[k] ~= v then
+return false
+end
+end
+return true

Review Comment:
   It seems that there is a problem with the logic here:
   
   https://github.com/user-attachments/assets/0257ee6e-20b9-4f93-bda3-77d97bac8eb7";
 />
   
   `route_metadata` will not be nil or empty



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



Re: [PR] feat(nacos): add metadata filtering support to nacos discovery [apisix]

2025-07-30 Thread via GitHub


SkyeYoung commented on code in PR #12445:
URL: https://github.com/apache/apisix/pull/12445#discussion_r2241982959


##
apisix/discovery/nacos/init.lua:
##
@@ -355,6 +374,19 @@ function _M.nodes(service_name, discovery_args)
 return nil
 end
 local nodes = core.json.decode(value)
+
+-- Apply metadata filtering if specified
+local route_metadata = discovery_args and discovery_args.metadata
+if route_metadata and next(route_metadata) then
+local filtered_nodes = {}
+for _, node in ipairs(nodes) do
+if metadata_contains(node.metadata, route_metadata) then
+core.table.insert(filtered_nodes, node)
+end
+end
+return filtered_nodes
+end
+

Review Comment:
   ditto



##
apisix/discovery/nacos/init.lua:
##
@@ -54,6 +55,23 @@ local function get_key(namespace_id, group_name, 
service_name)
 return namespace_id .. '.' .. group_name .. '.' .. service_name
 end
 
+
+local function metadata_contains(host_metadata, route_metadata)
+if not route_metadata or not next(route_metadata) then
+return true
+end
+if not host_metadata or not next(host_metadata) then
+return false
+end
+
+for k, v in pairs(route_metadata) do
+if host_metadata[k] ~= v then
+return false
+end
+end
+return true
+end

Review Comment:
   Can u abstract this func into a separate file for reuse?



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



Re: [PR] feat(nacos): add metadata filtering support to nacos discovery [apisix]

2025-07-21 Thread via GitHub


jizhuozhi commented on PR #12445:
URL: https://github.com/apache/apisix/pull/12445#issuecomment-3101148756

   > I don't think it's a duplicate at the moment. Using metadata to filter 
nacos services is a very useful feature. For more information, you can check 
the related issue.
   
   Got it, thanks for you reply :)
   
   This is used to filter when pulling the service list from service discovery 
to avoid pulling a large number of useless instances. We also have similar 
demands when using Consul. I will try to add the following.


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



Re: [PR] feat(nacos): add metadata filtering support to nacos discovery [apisix]

2025-07-20 Thread via GitHub


Baoyuantop commented on code in PR #12445:
URL: https://github.com/apache/apisix/pull/12445#discussion_r2218119593


##
apisix/discovery/nacos/init.lua:
##
@@ -54,6 +55,23 @@ local function get_key(namespace_id, group_name, 
service_name)
 return namespace_id .. '.' .. group_name .. '.' .. service_name
 end
 
+
+local function metadata_contains(host_metadata, route_metadata)

Review Comment:
   Could you explain what these two parameters mean?



##
t/discovery/nacos.t:
##
@@ -1066,3 +1066,124 @@ GET /t
 --- response_body
 server 1
 server 4
+
+
+
+=== TEST 27: get APISIX-NACOS info from NACOS - metadata filtering lane=a 
(only server1)
+--- yaml_config eval: $::yaml_config
+--- apisix_yaml
+routes:
+  -
+uri: /hello
+upstream:
+  service_name: APISIX-NACOS
+  discovery_type: nacos
+  type: roundrobin
+  discovery_args:
+metadata:
+  lane: "a"
+#END
+--- pipelined_requests eval
+[
+"GET /hello",
+"GET /hello",
+"GET /hello",
+"GET /hello",
+"GET /hello",
+]
+--- response_body_like eval
+[
+qr/server 1/,
+qr/server 1/,
+qr/server 1/,
+qr/server 1/,
+qr/server 1/,
+]
+
+
+
+=== TEST 28: get APISIX-NACOS info from NACOS - metadata filtering lane=b 
(only server2)

Review Comment:
   This case is somewhat repetitive, I think the configuration can be changed to
   ```
   discovery_args:
   metadata:
   ```
   Test the behavior of metadata being empty.



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



Re: [PR] feat(nacos): add metadata filtering support to nacos discovery [apisix]

2025-07-20 Thread via GitHub


Baoyuantop commented on PR #12445:
URL: https://github.com/apache/apisix/pull/12445#issuecomment-3095073292

   > There seems to be duplicate work #12448 (coincidentally, we have similar 
demands). According to my understanding of apisix, all routes share the same 
service discovery results, so it is not suitable to filter in the discovery.
   
   I don't think it's a duplicate at the moment. Using metadata to filter nacos 
services is a very useful feature. For more information, you can check the 
related issue.


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



Re: [PR] feat(nacos): add metadata filtering support to nacos discovery [apisix]

2025-07-20 Thread via GitHub


jizhuozhi commented on PR #12445:
URL: https://github.com/apache/apisix/pull/12445#issuecomment-3095061852

   There seems to be duplicate work https://github.com/apache/apisix/pull/12448 
(coincidentally, we have similar demands). According to my understanding of 
apisix, all routes share the same service discovery results, so it is not 
suitable to filter in the discovery.


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