codjust commented on a change in pull request #1022: Feature/chash key support 
more flexible ways
URL: https://github.com/apache/incubator-apisix/pull/1022#discussion_r363278370
 
 

 ##########
 File path: lua/apisix/balancer.lua
 ##########
 @@ -122,6 +123,38 @@ local function fetch_healthchecker(upstream, 
healthcheck_parent, version)
 end
 
 
+local function create_chash_hash_key(ctx, upstream)
+    local key = upstream.key
+    local hash_on = upstream.hash_on
+    local chash_key
+
+    -- hash_on is nil, compatible with old version, default vars
+    if not hash_on then
+        hash_on = "vars"
+    end
+
+    if hash_on == "consumer" then
+        chash_key = ctx.consumer_id
+    elseif hash_on == "vars" then
+        chash_key = ctx.var[key]
+    elseif hash_on == "header" then
+        chash_key = ngx.req.get_headers()[key]
 
 Review comment:
   get

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to