membphis 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_r363146088
########## File path: lua/apisix/admin/upstreams.lua ########## @@ -28,6 +28,59 @@ local _M = { } +local function get_chash_key_schema(hash_on) + if not hash_on then + return nil, "hash_on is nil" + end + + if hash_on == "vars" then + return core.schema.upstream_hash_vars_schema + end + + if hash_on == "header" or hash_on == "cookie" then + return core.schema.upstream_hash_header_schema + end + + if hash_on == "consumer" then + return nil, nil + end + + return nil, "invalid hash_on type " .. hash_on +end + + +local function check_upstream_conf(conf) + local ok, err = core.schema.check(core.schema.upstream, conf) + if not ok then + return false, {error_msg = "invalid configuration: " .. err} + end + + if conf.type == "chash" then Review comment: Bad code style. Here is the good style: ```lua if conf.type ~= "chash" then return true end if not conf.hash_on then conf.hash_on = "vars" end ... return 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services