cool, look forward to it.

Thanks,
Ming Wen, Apache APISIX
Twitter: _WenMing


codjust <[email protected]> 于2019年12月29日周日 下午10:51写道:

> I will submit a PR later, please review it together.
>
>
> ------------------&nbsp;原始邮件&nbsp;------------------
> 发件人:&nbsp;"Ming Wen"<[email protected]&gt;;
> 发送时间:&nbsp;2019年12月24日(星期二) 上午8:10
> 收件人:&nbsp;"dev"<[email protected]&gt;;
>
> 主题:&nbsp;Re: [DISCUSS] chash key support more flexible ways
>
>
>
> &gt;
> &gt; I do think we can learn this part from OpenResty Edge,
> &gt;
> This is the part of the dashboard display.
>
> I was wondering if the underlying code implementation needed a
> classification as codjust said? Or just sort on the dashboard?
>
> Thanks,
> Ming Wen, Apache APISIX
> Twitter: _WenMing
>
>
> 李凌 <[email protected]&gt; 于2019年12月23日周一 下午10:56写道:
>
> &gt; I do think we can learn this part from OpenResty Edge,
> &gt; also I like the idea that take a Chash key from Header ,which is
> pretty
> &gt; meaningful for us.
> &gt;
> &gt; [image: image.png]
> &gt;
> &gt;
> &gt; Ming Wen <[email protected]&gt; 于2019年12月23日周一 下午9:04写道:
> &gt;
> &gt;&gt; yuansheng, what do you think?
> &gt;&gt;
> &gt;&gt; Thanks,
> &gt;&gt; Ming Wen, Apache APISIX
> &gt;&gt; Twitter: _WenMing
> &gt;&gt;
> &gt;&gt;
> &gt;&gt; Ming Wen <[email protected]&gt; 于2019年12月23日周一 下午9:03写道:
> &gt;&gt;
> &gt;&gt; &gt; hi, codjust,
> &gt;&gt; &gt; I prefer your design than the existing one[1].
> &gt;&gt; &gt;
> &gt;&gt; &gt; These categories "vars", "header", "cookie", "consumer" are
> friendly for
> &gt;&gt; &gt; developer.
> &gt;&gt; &gt;
> &gt;&gt; &gt; [1]
> &gt;&gt; &gt;
> &gt;&gt;
> https://github.com/apache/incubator-apisix/blob/master/lua/apisix/schema_def.lua#L261
> &gt;&gt
> <https://github.com/apache/incubator-apisix/blob/master/lua/apisix/schema_def.lua#L261&gt;&gt>;
> &gt;
> &gt;&gt; &gt; Thanks,
> &gt;&gt; &gt; Ming Wen, Apache APISIX
> &gt;&gt; &gt; Twitter: _WenMing
> &gt;&gt; &gt;
> &gt;&gt; &gt;
> &gt;&gt; &gt; codjust <[email protected]&gt; 于2019年12月23日周一 下午8:58写道:
> &gt;&gt; &gt;
> &gt;&gt; &gt;&gt; Now chash key only support fetch from nginx variable. We
> need to be
> &gt;&gt; more
> &gt;&gt; &gt;&gt; flexible approach,
> &gt;&gt; &gt;&gt; eg: cookie, custom header and so on.
> &gt;&gt; &gt;&gt; Here is an example to achieve:
> &gt;&gt; &gt;&gt; upstream json schema:
> &gt;&gt; &gt;&gt; hash_on = {
> &gt;&gt; &gt;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;
> &amp;nbsp; type = "string",
> &gt;&gt; &gt;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;
> &amp;nbsp; default = "vars",
> &gt;&gt; &gt;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;
> &amp;nbsp; enum = {
> &gt;&gt; &gt;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;
> &amp;nbsp; &amp;nbsp; "vars",
> &gt;&gt; &gt;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;
> &amp;nbsp; &amp;nbsp; "header",
> &gt;&gt; &gt;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;
> &amp;nbsp; &amp;nbsp; "cookie",
> &gt;&gt; &gt;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;
> &amp;nbsp; &amp;nbsp; "consumer"
> &gt;&gt; &gt;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;
> &amp;nbsp; },
> &gt;&gt; &gt;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; },
> &gt;&gt; &gt;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; key = {
> &gt;&gt; &gt;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;
> &amp;nbsp; description = "the key of
> &gt;&gt; chash
> &gt;&gt; &gt;&gt; for dynamic load balancing",
> &gt;&gt; &gt;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;
> &amp;nbsp; type = "string"
> &gt;&gt; &gt;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; },
> &gt;&gt; &gt;&gt;
> &gt;&gt; &gt;&gt;
> &gt;&gt; &gt;&gt; eg:
> &gt;&gt; &gt;&gt; local function create_chash_hash_key(ctx, upstream)
> &gt;&gt; &gt;&gt; &amp;nbsp; &amp;nbsp; local key = upstream.key&amp;nbsp;
> &gt;&gt; &gt;&gt; &amp;nbsp; &amp;nbsp; local hash_on = upstream.hash_on
> &gt;&gt; &gt;&gt; &amp;nbsp; &amp;nbsp; local chash_key
> &gt;&gt; &gt;&gt; &amp;nbsp; &amp;nbsp; -- from nginx variable
> &gt;&gt; &gt;&gt; &amp;nbsp; &amp;nbsp; if hash_on == "vars" then&amp;nbsp;
> &gt;&gt; &gt;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; chash_key =
> ctx.var[key]
> &gt;&gt; &gt;&gt; &amp;nbsp; &amp;nbsp; elseif hash_on == "header"
> then&amp;nbsp;
> &gt;&gt; &gt;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; chash_key =
> ngx.req.get_headers()[key]
> &gt;&gt; &gt;&gt; &amp;nbsp; &amp;nbsp; elseif hash_on == "cookie"
> then&amp;nbsp;
> &gt;&gt; &gt;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; chash_key =
> ctx.var["cookie_" .. key]
> &gt;&gt; &gt;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; -- TODO
> chash_key doesn't exist, set-cookie
> &gt;&gt; &gt;&gt; &amp;nbsp; &amp;nbsp; end
> &gt;&gt; &gt;&gt; &amp;nbsp; &amp;nbsp; if not chash_key then&amp;nbsp;
> &gt;&gt; &gt;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; chash_key =
> ctx.var["remote_addr"]
> &gt;&gt; &gt;&gt; &amp;nbsp; &amp;nbsp; end
> &gt;&gt; &gt;&gt; &amp;nbsp; &amp;nbsp; return chash_key
> &gt;&gt; &gt;&gt; end
> &gt;&gt; &gt;&gt;
> &gt;&gt; &gt;&gt;
> &gt;&gt; &gt;&gt; hash_on type desc:
> &gt;&gt; &gt;&gt; 1 vars: fetchs nginx variable
> &gt;&gt; &gt;&gt; 2 header: custom headers or standard http headers
> &gt;&gt; &gt;&gt; 3 cookie: fetch chash key from cookie. It can be used to
> sticky session
> &gt;&gt; &gt;&gt; 4 consumer: hash by consumer_id
> &gt;&gt; &gt;&gt; If the specified chash key is not present, use default
> key:
> &gt;&gt; &gt;&gt; remote_addr(it can also provide default settings).
> &gt;&gt; &gt;&gt;
> &gt;&gt; &gt;&gt;
> &gt;&gt; &gt;&gt; everybody have a better idea?
> &gt;&gt; &gt;&gt;
> &gt;&gt; &gt;&gt; github issue:
> &gt;&gt; &gt;&gt; https://github.com/apache/incubator-apisix/issues/992
> &gt;&gt <https://github.com/apache/incubator-apisix/issues/992&gt;&gt>;
> &gt;
> &gt;&gt; &gt;
> &gt;&gt;
> &gt;

Reply via email to