Copilot commented on code in PR #12448:
URL: https://github.com/apache/apisix/pull/12448#discussion_r2255636406


##########
docs/en/latest/discovery/consul.md:
##########
@@ -232,6 +232,61 @@ $ curl http://127.0.0.1:9180/apisix/admin/stream_routes/1 
-H "X-API-KEY: $admin_
 }'
 ```
 
+### discovery_args
+
+| Name           | Type   | Requirement | Default | Valid | Description        
                                          |
+|----------------| ------ | ----------- | ------- | ----- | 
------------------------------------------------------------ |
+| metadata_match | object | optional    | {}      |       | Filter service 
instances by metadata using containment matching |
+
+#### Metadata filtering
+
+APISIX supports filtering service instances based on metadata. When a route is 
configured with metadata conditions, only service instances whose metadata 
matched with roles specified in the route's `metadata_match` 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", "b"], env: "prod"}`, but not routes configured with `{lane: 
["c"]}` 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",

Review Comment:
   The discovery_type should be 'consul' not 'nacos' in the Consul 
documentation examples.
   ```suggestion
           "discovery_type": "consul",
   ```



##########
docs/en/latest/discovery/consul.md:
##########
@@ -232,6 +232,61 @@ $ curl http://127.0.0.1:9180/apisix/admin/stream_routes/1 
-H "X-API-KEY: $admin_
 }'
 ```
 
+### discovery_args
+
+| Name           | Type   | Requirement | Default | Valid | Description        
                                          |
+|----------------| ------ | ----------- | ------- | ----- | 
------------------------------------------------------------ |
+| metadata_match | object | optional    | {}      |       | Filter service 
instances by metadata using containment matching |
+
+#### Metadata filtering
+
+APISIX supports filtering service instances based on metadata. When a route is 
configured with metadata conditions, only service instances whose metadata 
matched with roles specified in the route's `metadata_match` 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", "b"], env: "prod"}`, but not routes configured with `{lane: 
["c"]}` 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",

Review Comment:
   The documentation example shows Nacos service name and URI paths but this is 
Consul documentation. The example should use Consul-specific service names and 
paths to avoid confusion.
   ```suggestion
       "uri": "/consulWithMetadata/*",
       "upstream": {
           "service_name": "APISIX-CONSUL",
           "type": "roundrobin",
           "discovery_type": "consul",
   ```



##########
docs/en/latest/discovery/consul.md:
##########
@@ -232,6 +232,61 @@ $ curl http://127.0.0.1:9180/apisix/admin/stream_routes/1 
-H "X-API-KEY: $admin_
 }'
 ```
 
+### discovery_args
+
+| Name           | Type   | Requirement | Default | Valid | Description        
                                          |
+|----------------| ------ | ----------- | ------- | ----- | 
------------------------------------------------------------ |
+| metadata_match | object | optional    | {}      |       | Filter service 
instances by metadata using containment matching |
+
+#### Metadata filtering
+
+APISIX supports filtering service instances based on metadata. When a route is 
configured with metadata conditions, only service instances whose metadata 
matched with roles specified in the route's `metadata_match` 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", "b"], env: "prod"}`, but not routes configured with `{lane: 
["c"]}` 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",

Review Comment:
   The service name 'APISIX-NACOS' is incorrect for Consul documentation. It 
should be a Consul service name to match the context.
   ```suggestion
           "service_name": "APISIX-CONSUL",
           "type": "roundrobin",
           "discovery_type": "consul",
   ```



##########
docs/en/latest/discovery/consul.md:
##########
@@ -232,6 +232,61 @@ $ curl http://127.0.0.1:9180/apisix/admin/stream_routes/1 
-H "X-API-KEY: $admin_
 }'
 ```
 
+### discovery_args
+
+| Name           | Type   | Requirement | Default | Valid | Description        
                                          |
+|----------------| ------ | ----------- | ------- | ----- | 
------------------------------------------------------------ |
+| metadata_match | object | optional    | {}      |       | Filter service 
instances by metadata using containment matching |
+
+#### Metadata filtering
+
+APISIX supports filtering service instances based on metadata. When a route is 
configured with metadata conditions, only service instances whose metadata 
matched with roles specified in the route's `metadata_match` 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", "b"], env: "prod"}`, but not routes configured with `{lane: 
["c"]}` 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", "v2"]
+          }
+        }
+    }
+}'
+```
+
+This route will only route traffic to service instances that have the metadata 
field `version` set to `v1` or `v2`.
+
+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",

Review Comment:
   The discovery_type should be 'consul' not 'nacos' in this Consul 
documentation.
   ```suggestion
           "discovery_type": "consul",
   ```



##########
docs/en/latest/discovery/consul.md:
##########
@@ -232,6 +232,61 @@ $ curl http://127.0.0.1:9180/apisix/admin/stream_routes/1 
-H "X-API-KEY: $admin_
 }'
 ```
 
+### discovery_args
+
+| Name           | Type   | Requirement | Default | Valid | Description        
                                          |
+|----------------| ------ | ----------- | ------- | ----- | 
------------------------------------------------------------ |
+| metadata_match | object | optional    | {}      |       | Filter service 
instances by metadata using containment matching |
+
+#### Metadata filtering
+
+APISIX supports filtering service instances based on metadata. When a route is 
configured with metadata conditions, only service instances whose metadata 
matched with roles specified in the route's `metadata_match` 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", "b"], env: "prod"}`, but not routes configured with `{lane: 
["c"]}` 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", "v2"]
+          }
+        }
+    }
+}'
+```
+
+This route will only route traffic to service instances that have the metadata 
field `version` set to `v1` or `v2`.
+
+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",

Review Comment:
   The service name 'APISIX-NACOS' is incorrect for Consul documentation. 
Should be a Consul service name.
   ```suggestion
           "service_name": "APISIX-CONSUL",
           "type": "roundrobin",
           "discovery_type": "consul",
   ```



##########
docs/en/latest/discovery/consul.md:
##########
@@ -232,6 +232,61 @@ $ curl http://127.0.0.1:9180/apisix/admin/stream_routes/1 
-H "X-API-KEY: $admin_
 }'
 ```
 
+### discovery_args
+
+| Name           | Type   | Requirement | Default | Valid | Description        
                                          |
+|----------------| ------ | ----------- | ------- | ----- | 
------------------------------------------------------------ |
+| metadata_match | object | optional    | {}      |       | Filter service 
instances by metadata using containment matching |
+
+#### Metadata filtering
+
+APISIX supports filtering service instances based on metadata. When a route is 
configured with metadata conditions, only service instances whose metadata 
matched with roles specified in the route's `metadata_match` 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", "b"], env: "prod"}`, but not routes configured with `{lane: 
["c"]}` 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", "v2"]
+          }
+        }
+    }
+}'
+```
+
+This route will only route traffic to service instances that have the metadata 
field `version` set to `v1` or `v2`.
+
+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": {

Review Comment:
   The field name should be 'metadata_match' not 'metadata' according to the 
schema definition.
   ```suggestion
             "metadata_match": {
   ```



##########
docs/en/latest/discovery/consul.md:
##########
@@ -232,6 +232,61 @@ $ curl http://127.0.0.1:9180/apisix/admin/stream_routes/1 
-H "X-API-KEY: $admin_
 }'
 ```
 
+### discovery_args
+
+| Name           | Type   | Requirement | Default | Valid | Description        
                                          |
+|----------------| ------ | ----------- | ------- | ----- | 
------------------------------------------------------------ |
+| metadata_match | object | optional    | {}      |       | Filter service 
instances by metadata using containment matching |
+
+#### Metadata filtering
+
+APISIX supports filtering service instances based on metadata. When a route is 
configured with metadata conditions, only service instances whose metadata 
matched with roles specified in the route's `metadata_match` 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", "b"], env: "prod"}`, but not routes configured with `{lane: 
["c"]}` 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": {

Review Comment:
   The field name should be 'metadata_match' not 'metadata' according to the 
schema definition and implementation.
   ```suggestion
             "metadata_match": {
   ```



##########
docs/en/latest/discovery/consul.md:
##########
@@ -232,6 +232,61 @@ $ curl http://127.0.0.1:9180/apisix/admin/stream_routes/1 
-H "X-API-KEY: $admin_
 }'
 ```
 
+### discovery_args
+
+| Name           | Type   | Requirement | Default | Valid | Description        
                                          |
+|----------------| ------ | ----------- | ------- | ----- | 
------------------------------------------------------------ |
+| metadata_match | object | optional    | {}      |       | Filter service 
instances by metadata using containment matching |
+
+#### Metadata filtering
+
+APISIX supports filtering service instances based on metadata. When a route is 
configured with metadata conditions, only service instances whose metadata 
matched with roles specified in the route's `metadata_match` 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", "b"], env: "prod"}`, but not routes configured with `{lane: 
["c"]}` 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", "v2"]
+          }
+        }
+    }
+}'
+```
+
+This route will only route traffic to service instances that have the metadata 
field `version` set to `v1` or `v2`.
+
+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",

Review Comment:
   The URI path references 'nacos' but this is Consul documentation. Should use 
Consul-appropriate naming.
   ```suggestion
       "uri": "/consulWithMultipleMetadata/*",
       "upstream": {
           "service_name": "APISIX-CONSUL",
           "type": "roundrobin",
           "discovery_type": "consul",
   ```



-- 
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: notifications-unsubscr...@apisix.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to