[GitHub] [apisix] alex8224 edited a comment on issue #5706: request help: How to route according to the configuration of nacos metadata?

2021-12-07 Thread GitBox


alex8224 edited a comment on issue #5706:
URL: https://github.com/apache/apisix/issues/5706#issuecomment-988023902


   @tzssangglass 
   **If so, that's pretty good**
   
   Generally use the 
127.0.0.1:8848/nacos/v1/ns/instance/list?serviceName=xxx&namespaceId=dev 
interface to get all service instances under a namespaceId, The output of the 
interface call is as follows
   
   ```json
   {
  "allIPs":false,
  "cacheMillis":1,
  "checksum":"",
  "clusters":"",
  "groupName":"DEFAULT_GROUP",
  "hosts":[
 {
"clusterName":"DEFAULT",
"enabled":true,
"ephemeral":true,
"healthy":true,
"instanceHeartBeatInterval":5000,
"instanceHeartBeatTimeOut":15000,
"instanceId":"192.26.0.7#9088#DEFAULT#DEFAULT_GROUP@@xxx",
"ip":"192.26.0.7",
"ipDeleteTimeout":3,
"metadata":{
   "app.name":"xxx",
   "preserved.register.source":"SPRING_CLOUD",
   "startup.time":"1638849194096",
   "dept":"HR"
},
"port":9088,
"serviceName":"DEFAULT_GROUP@@xxx",
"weight":1.0
 },
 {
"clusterName":"DEFAULT",
"enabled":true,
"ephemeral":true,
"healthy":true,
"instanceHeartBeatInterval":5000,
"instanceHeartBeatTimeOut":15000,
"instanceId":"192.26.0.6#9088#DEFAULT#DEFAULT_GROUP@@xxx",
"ip":"192.26.0.6",
"ipDeleteTimeout":3,
"metadata":{
   "app.name":"xxx",
   "preserved.register.source":"SPRING_CLOUD",
   "startup.time":"1638849194096",
   "dept":"IT"
},
"port":9088,
"serviceName":"DEFAULT_GROUP@@xxx",
"weight":1.0
 },
 {
"clusterName":"DEFAULT",
"enabled":true,
"ephemeral":true,
"healthy":true,
"instanceHeartBeatInterval":5000,
"instanceHeartBeatTimeOut":15000,
"instanceId":"192.26.0.9#9088#DEFAULT#DEFAULT_GROUP@@xxx",
"ip":"192.26.0.9",
"ipDeleteTimeout":3,
"metadata":{
   "app.name":"xxx",
   "preserved.register.source":"SPRING_CLOUD",
   "startup.time":"1638849194096",
   "dept":"HRP"
},
"port":9088,
"serviceName":"DEFAULT_GROUP@@xxx",
"weight":1.0
 }
  ],
  "lastRefTime":1638890095796,
  "name":"DEFAULT_GROUP@@bcs-server",
  "reachProtectionThreshold":false,
  "valid":true
   }```
   
   
   
   There are several scenarios as follows
   route url = /xxx/*
   When the client requests /xxx/*
   When header ["X-Real-Ip"] between ["192.168.1-192.168.1.10"], the request is 
routed to the instance node with metadata field dept == HR, in this case node 
192.26.0.7
   Other requests that do not match are routed to nodes that do not match, in 
this case to 192.26.0.6 and 192.26.0.9
   
   


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




[GitHub] [apisix] alex8224 edited a comment on issue #5706: request help: How to route according to the configuration of nacos metadata?

2021-12-06 Thread GitBox


alex8224 edited a comment on issue #5706:
URL: https://github.com/apache/apisix/issues/5706#issuecomment-986914757


   > > @alex8224 You may implement your own balancer and use it in `Upstream` 
objects.
   > 
   > See 
https://apisix.apache.org/blog/2021/07/28/release-apache-apisix-2.8/#new-way-to-develop-support-for-custom-balancer
 .
   @tokers 
   I can only find very little about how to implement a balancer from the url 
you gave, are there other more detailed guides on how to easily add a balancer 
type?
   For example.
   1. at what stage does the nacos metadata information get and where is it 
placed?
   2. where to add require("apisix.balancer.your_balancer")?
   3. what functions should I implement in my custom balancer?
   


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




[GitHub] [apisix] alex8224 edited a comment on issue #5706: request help: How to route according to the configuration of nacos metadata?

2021-12-06 Thread GitBox


alex8224 edited a comment on issue #5706:
URL: https://github.com/apache/apisix/issues/5706#issuecomment-986914757


   > > @alex8224 You may implement your own balancer and use it in `Upstream` 
objects.
   > 
   > See 
https://apisix.apache.org/blog/2021/07/28/release-apache-apisix-2.8/#new-way-to-develop-support-for-custom-balancer
 .
   
   I can only find very little about how to implement a balancer from the url 
you gave, are there other more detailed guides on how to easily add a balancer 
type?
   For example.
   1. at what stage does the nacos metadata information get and where is it 
placed?
   2. where to add require("apisix.balancer.your_balancer")?
   3. what functions should I implement in my custom balancer?
   


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