CNSRE / ABTestingGateway

MIT License
2.35k stars 768 forks source link

ABTestionGateway扩展分流类型问题咨询 #49

Open zhangsheng123 opened 7 years ago

zhangsheng123 commented 7 years ago

咨询一下如何扩展分流策略,比如我现在要按照参数年龄age分流,我按照以前有同事提供的,在init.luaabtesting\utils 的init.lua中_M.divtypes添加 ["arg_age"] = 'ageParser',然后启动,我添加策略时报错,如下所示: [root@data2-node utils]# curl 127.0.0.1:8080/ab_admin?action=policy_set -d '{"divtype":"arg_age","divdata":[{"age":"1","upstream":"data1"},{"age":"2","upstream":"core"}]}' {"code":40201,"desc":"lua runtime error ..\/lib\/abtesting\/adapter\/policy.lua:95: module 'abtesting.diversion.arg_age' not found:\n\tno field package.preload['abtesting.diversion.arg_age']\n\tno file '..\/abtesting\/diversion\/arg_age.lua'\n\tno file '..\/lib\/abtesting\/diversion\/arg_age.lua'\n\tno file '..\/lib\/lua-resty-core\/lib\/abtesting\/diversion\/arg_age.lua'\n\tno file '\/usr\/local\/openresty\/lualib\/abtesting\/diversion\/arg_age.lua'\n\tno file '\/usr\/local\/openresty\/lualib\/abtesting\/diversion\/arg_age\/init.lua'\n\tno file '.\/abtesting\/diversion\/arg_age.lua'\n\tno file '\/usr\/local\/openresty\/luajit\/share\/luajit-2.1.0-beta1\/abtesting\/diversion\/arg_age.lua'\n\tno file '\/usr\/local\/share\/lua\/5.1\/abtesting\/diversion\/arg_age.lua'\n\tno file '\/usr\/local\/share\/lua\/5.1\/abtesting\/diversion\/arg_age\/init.lua'\n\tno file '\/usr\/local\/openresty\/luajit\/share\/lua\/5.1\/abtesting\/diversion\/arg_age.lua'\n\tno file '\/usr\/local\/openresty\/luajit\/share\/lua\/5.1\/abtesting\/diversion\/arg_age\/init.lua'\n\tno file '\/usr\/local\/openresty\/lualib\/abtesting\/diversion\/arg_age.so'\n\tno file '.\/abtesting\/diversion\/arg_age.so'\n\tno file '\/usr\/local\/lib\/lua\/5.1\/abtesting\/diversion\/arg_age.so'\n\tno file '\/usr\/local\/openresty\/luajit\/lib\/lua\/5.1\/abtesting\/diversion\/arg_age.so'\n\tno file '\/usr\/local\/lib\/lua\/5.1\/loadall.so'\n\tno file '\/usr\/local\/openresty\/lualib\/abtesting.so'\n\tno file '.\/abtesting.so'\n\tno file '\/usr\/local\/lib\/lua\/5.1\/abtesting.so'\n\tno file '\/usr\/local\/openresty\/luajit\/lib\/lua\/5.1\/abtesting.so'\n\tno file '\/usr\/local\/lib\/lua\/5.1\/loadall.so'"}

BG2BKK commented 7 years ago

你好,需要自己写'abtesting/diversion/arg_age.lua作为分流逻辑,可以参考uidsuffix

On Fri, Nov 25, 2016 at 10:49 AM, zhangsheng123 notifications@github.com wrote:

咨询一下如何扩展分流策略,比如我现在要按照参数年龄age分流,我按照以前有同事提供的,在init.luaabtesting\utils 的init.lua中_M.divtypes添加 ["arg_age"] = 'ageParser',然后启动,我添加策略时报错,如下所示: [root@data2-node utils]# curl 127.0.0.1:8080/ab_admin?action=policy_set -d '{"divtype":"arg_age","divdata":[{"age":"1"," upstream":"data1"},{"age":"2","upstream":"core"}]}' {"code":40201,"desc":"lua runtime error ../lib/abtesting/adapter/policy.lua:95: module 'abtesting.diversion.arg_age' not found:\n\tno field package.preload['abtesting.diversion.arg_age']\n\tno file '../abtesting/diversion/arg_age.lua'\n\tno file '../lib/abtesting/diversion/arg_age.lua'\n\tno file '../lib/lua-resty-core/lib/abtesting/diversion/arg_age.lua'\n\tno file '/usr/local/openresty/lualib/abtesting/diversion/arg_age.lua'\n\tno file '/usr/local/openresty/lualib/abtesting/diversion/arg_age/init.lua'\n\tno file './abtesting/diversion/arg_age.lua'\n\tno file '/usr/local/openresty/luajit/share/luajit-2.1.0-beta1/ abtesting/diversion/arg_age.lua'\n\tno file '/usr/local/share/lua/5.1/ abtesting/diversion/arg_age.lua'\n\tno file '/usr/local/share/lua/5.1/ abtesting/diversion/arg_age/init.lua'\n\tno file '/usr/local/openresty/luajit/share/lua/5.1/abtesting/diversion/arg_age.lua'\n\tno file '/usr/local/openresty/luajit/share/lua/5.1/abtesting/ diversion/arg_age/init.lua'\n\tno file '/usr/local/openresty/lualib/ abtesting/diversion/arg_age.so'\n\tno file './abtesting/diversion/arg_age.so'\n\tno file '/usr/local/lib/lua/5.1/abtesting/diversion/arg_age.so'\n\tno file '/usr/local/openresty/luajit/lib/lua/5.1/abtesting/diversion/arg_age.so'\n\tno file '/usr/local/lib/lua/5.1/loadall.so'\n\tno file '/usr/local/openresty/lualib/abtesting.so'\n\tno file './abtesting.so'\n\tno file '/usr/local/lib/lua/5.1/abtesting.so'\n\tno file '/usr/local/openresty/luajit/lib/lua/5.1/abtesting.so'\n\tno file '/usr/local/lib/lua/5.1/loadall.so'"}

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/CNSRE/ABTestingGateway/issues/49, or mute the thread https://github.com/notifications/unsubscribe-auth/AA0sgaBzbqWrKWOhasWmbR3hclpEfm9Uks5rBky-gaJpZM4K8Ea1 .

-- 黄振栋 bg2bkk@gmail.com Phone:15010359288 personal site: https://bg2bkk.github.io