xBoo commented on issue #11342:
URL: https://github.com/apache/apisix/issues/11342#issuecomment-2172389516

   I found an implementation, which is done through the following code:
   
[dymainc_uri_upstream.lua](https://gist.github.com/br41n10/e2d378c7a04d4861b2f0cbf4d2476d71)
   ```code
    local up_conf = {
           timeout = {
               connect = 6,
               send = 300,
               read = 300
           },
           scheme = "http",
           type = "roundrobin",
           pass_host = "pass",
           keepalive_pool = {
               idle_timeout = 60,
               requests = 1000,
               size = 320
           },
           hash_on = "vars",
           nodes = {
               {
                   priority = 0,
                   port = upstream_port,
                   host = parse_domain(upstream_host),
                   weight = 1
               }
           }
       }
   
       local ok, err = upstream.check_schema(up_conf)
       if not ok then
           core.log.error("failed to validate generated upstream: ", err)
           return 500, err
       end
   
       local matched_route = ctx.matched_route
       up_conf.parent = matched_route
       local upstream_key = up_conf.type .. "#route_" .. matched_route.value.id
       core.log.info("upstream_key: ", upstream_key)
   
       upstream.set(ctx, upstream_key, ctx.conf_version, up_conf)
   ```
   But I don't think it's a best practice because many parameters become fixed 
values and cannot be dynamically configured.
   I found that it can also be achieved by setting the upstream_id, but I don't 
know what the risks are.
   


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