Skip to content

Commit ca64066

Browse files
committed
feat: v3.4.0版本更新
feat: 支持负载详情多维度统计和展示 feat: 支持waf详情多维度统计和展示 feat: 支持管理后台退出登陆 feat: 优化代码注释 feat: 即将支持grpc代理插件 feat: 事务日程调整
1 parent 6ecac02 commit ca64066

File tree

99 files changed

+4101
-489
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+4101
-489
lines changed
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
-- tl_ops_api
2+
-- en : get balance api count data list
3+
-- zn : 获取路由负载详情列表
4+
-- @author iamtsm
5+
-- @email 1905333456@qq.com
6+
7+
local cache = require("cache.tl_ops_cache_core"):new("tl-ops-balance-count");
8+
local cache_balance_api = require("cache.tl_ops_cache_core"):new("tl-ops-balance-api")
9+
local tl_ops_rt = require("constant.tl_ops_constant_comm").tl_ops_rt;
10+
local tl_ops_utils_func = require("utils.tl_ops_utils_func");
11+
local tl_ops_constant_balance_api = require("constant.tl_ops_constant_balance_api")
12+
local tl_ops_constant_balance_count = require("constant.tl_ops_constant_balance_count")
13+
local cjson = require("cjson.safe");
14+
cjson.encode_empty_table_as_object(false)
15+
16+
local Router = function()
17+
18+
-- 支持只获取某个服务节点的路由规则统计
19+
local args = ngx.req.get_uri_args()
20+
local args_service = args['service']
21+
local args_node = args['node']
22+
args_node = tonumber(args_node)
23+
24+
local rule, _ = cache_balance_api:get(tl_ops_constant_balance_api.cache_key.rule);
25+
if not rule or rule == nil then
26+
tl_ops_utils_func:set_ngx_req_return_ok(tl_ops_rt.args_error ,"bca args err1", _);
27+
return;
28+
end
29+
30+
local list_str, _ = cache_balance_api:get(tl_ops_constant_balance_api.cache_key.list);
31+
if not list_str or list_str == nil then
32+
tl_ops_utils_func:set_ngx_req_return_ok(tl_ops_rt.args_error ,"bca args err2", _);
33+
return;
34+
end
35+
36+
local list = cjson.decode(list_str);
37+
if not list or list == nil then
38+
tl_ops_utils_func:set_ngx_req_return_ok(tl_ops_rt.args_error ,"bca args err3", _);
39+
return;
40+
end
41+
42+
local api_rule_list = list[rule];
43+
if not api_rule_list or api_rule_list == nil then
44+
tl_ops_utils_func:set_ngx_req_return_ok(tl_ops_rt.args_error ,"bca args err4", _);
45+
return;
46+
end
47+
48+
local res_data = {}
49+
50+
for _, api in ipairs(api_rule_list) do
51+
repeat
52+
local id = api.id;
53+
local service_name = api.service;
54+
local node_id = api.node;
55+
56+
if not id then
57+
break
58+
end
59+
if not service_name then
60+
break
61+
end
62+
if rule == tl_ops_constant_balance_api.rule.point then
63+
if node_id == nil or node_id == '' then
64+
break
65+
end
66+
end
67+
68+
if args_service and args_service ~= service_name then
69+
break
70+
end
71+
if args_node ~= nil and args_node ~= "" and node_id ~= args_node then
72+
break
73+
end
74+
75+
local api_counting_list = cache:get001(
76+
tl_ops_utils_func:gen_node_key( tl_ops_constant_balance_count.cache_key.api_counting_list, service_name, node_id, id)
77+
)
78+
if not api_counting_list then
79+
api_counting_list = "{}"
80+
end
81+
82+
table.insert(res_data, {
83+
id = id,
84+
service_name = service_name,
85+
node_id = node_id,
86+
content = api.url,
87+
count_list = cjson.decode(api_counting_list)
88+
})
89+
break
90+
until true
91+
end
92+
93+
tl_ops_utils_func:set_ngx_req_return_ok(tl_ops_rt.ok, "success", res_data);
94+
end
95+
96+
return Router
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
-- tl_ops_api
2+
-- en : get balance body count data list
3+
-- zn : 获取路由负载详情列表
4+
-- @author iamtsm
5+
-- @email 1905333456@qq.com
6+
7+
local cache = require("cache.tl_ops_cache_core"):new("tl-ops-balance-count");
8+
local cache_balance_body = require("cache.tl_ops_cache_core"):new("tl-ops-balance-body")
9+
local tl_ops_rt = require("constant.tl_ops_constant_comm").tl_ops_rt;
10+
local tl_ops_utils_func = require("utils.tl_ops_utils_func");
11+
local tl_ops_constant_balance_body = require("constant.tl_ops_constant_balance_body")
12+
local tl_ops_constant_balance_count = require("constant.tl_ops_constant_balance_count")
13+
local cjson = require("cjson.safe");
14+
cjson.encode_empty_table_as_object(false)
15+
16+
local Router = function()
17+
18+
-- 支持只获取某个服务节点的路由规则统计
19+
local args = ngx.req.get_uri_args()
20+
local args_service = args['service']
21+
local args_node = args['node']
22+
args_node = tonumber(args_node)
23+
24+
local rule, _ = cache_balance_body:get(tl_ops_constant_balance_body.cache_key.rule);
25+
if not rule or rule == nil then
26+
tl_ops_utils_func:set_ngx_req_return_ok(tl_ops_rt.args_error ,"bc args err1", _);
27+
return;
28+
end
29+
30+
local list_str, _ = cache_balance_body:get(tl_ops_constant_balance_body.cache_key.list);
31+
if not list_str or list_str == nil then
32+
tl_ops_utils_func:set_ngx_req_return_ok(tl_ops_rt.args_error ,"bc args err2", _);
33+
return;
34+
end
35+
36+
local list = cjson.decode(list_str);
37+
if not list or list == nil then
38+
tl_ops_utils_func:set_ngx_req_return_ok(tl_ops_rt.args_error ,"bc args err3", _);
39+
return;
40+
end
41+
42+
local body_rule_list = list[rule];
43+
if not body_rule_list or body_rule_list == nil then
44+
tl_ops_utils_func:set_ngx_req_return_ok(tl_ops_rt.args_error ,"bc args err4", _);
45+
return;
46+
end
47+
48+
local res_data = {}
49+
50+
for _, body in ipairs(body_rule_list) do
51+
repeat
52+
local id = body.id;
53+
local service_name = body.service;
54+
local node_id = body.node;
55+
56+
if not id then
57+
break
58+
end
59+
if not service_name then
60+
break
61+
end
62+
if rule == tl_ops_constant_balance_body.rule.point then
63+
if node_id == nil or node_id == '' then
64+
break
65+
end
66+
end
67+
68+
-- 支持只获取某个服务节点的路由规则统计
69+
if args_service and args_service ~= service_name then
70+
break
71+
end
72+
if args_node ~= nil and args_node ~= "" and node_id ~= args_node then
73+
break
74+
end
75+
76+
local body_counting_list = cache:get001(
77+
tl_ops_utils_func:gen_node_key( tl_ops_constant_balance_count.cache_key.body_counting_list, service_name, node_id, id)
78+
)
79+
if not body_counting_list then
80+
body_counting_list = "{}"
81+
end
82+
83+
table.insert(res_data, {
84+
id = id,
85+
service_name = service_name,
86+
node_id = node_id,
87+
content = body.body,
88+
count_list = cjson.decode(body_counting_list)
89+
})
90+
break
91+
until true
92+
end
93+
94+
tl_ops_utils_func:set_ngx_req_return_ok(tl_ops_rt.ok, "success", res_data);
95+
end
96+
97+
return Router
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
-- tl_ops_api
2+
-- en : get balance cookie count data list
3+
-- zn : 获取路由负载详情列表
4+
-- @author iamtsm
5+
-- @email 1905333456@qq.com
6+
7+
local cache = require("cache.tl_ops_cache_core"):new("tl-ops-balance-count");
8+
local cache_balance_cookie = require("cache.tl_ops_cache_core"):new("tl-ops-balance-cookie")
9+
local tl_ops_rt = require("constant.tl_ops_constant_comm").tl_ops_rt;
10+
local tl_ops_utils_func = require("utils.tl_ops_utils_func");
11+
local tl_ops_constant_balance_cookie = require("constant.tl_ops_constant_balance_cookie")
12+
local tl_ops_constant_balance_count = require("constant.tl_ops_constant_balance_count")
13+
local cjson = require("cjson.safe");
14+
cjson.encode_empty_table_as_object(false)
15+
16+
local Router = function()
17+
18+
-- 支持只获取某个服务节点的路由规则统计
19+
local args = ngx.req.get_uri_args()
20+
local args_service = args['service']
21+
local args_node = args['node']
22+
args_node = tonumber(args_node)
23+
24+
local rule, _ = cache_balance_cookie:get(tl_ops_constant_balance_cookie.cache_key.rule);
25+
if not rule or rule == nil then
26+
tl_ops_utils_func:set_ngx_req_return_ok(tl_ops_rt.args_error ,"bc args err1", _);
27+
return;
28+
end
29+
30+
local list_str, _ = cache_balance_cookie:get(tl_ops_constant_balance_cookie.cache_key.list);
31+
if not list_str or list_str == nil then
32+
tl_ops_utils_func:set_ngx_req_return_ok(tl_ops_rt.args_error ,"bc args err2", _);
33+
return;
34+
end
35+
36+
local list = cjson.decode(list_str);
37+
if not list or list == nil then
38+
tl_ops_utils_func:set_ngx_req_return_ok(tl_ops_rt.args_error ,"bc args err3", _);
39+
return;
40+
end
41+
42+
local cookie_rule_list = list[rule];
43+
if not cookie_rule_list or cookie_rule_list == nil then
44+
tl_ops_utils_func:set_ngx_req_return_ok(tl_ops_rt.args_error ,"bc args err4", _);
45+
return;
46+
end
47+
48+
local res_data = {}
49+
50+
for _, cookie in ipairs(cookie_rule_list) do
51+
repeat
52+
local id = cookie.id;
53+
local service_name = cookie.service;
54+
local node_id = cookie.node;
55+
56+
if not id then
57+
break
58+
end
59+
if not service_name then
60+
break
61+
end
62+
if rule == tl_ops_constant_balance_cookie.rule.point then
63+
if node_id == nil or node_id == '' then
64+
break
65+
end
66+
end
67+
68+
-- 支持只获取某个服务节点的路由规则统计
69+
if args_service and args_service ~= service_name then
70+
break
71+
end
72+
if args_node ~= nil and args_node ~= "" and node_id ~= args_node then
73+
break
74+
end
75+
76+
local cookie_counting_list = cache:get001(
77+
tl_ops_utils_func:gen_node_key( tl_ops_constant_balance_count.cache_key.cookie_counting_list, service_name, node_id, id)
78+
)
79+
if not cookie_counting_list then
80+
cookie_counting_list = "{}"
81+
end
82+
83+
table.insert(res_data, {
84+
id = id,
85+
service_name = service_name,
86+
node_id = node_id,
87+
content = cjson.encode({
88+
key = cookie.key,
89+
value = cookie.value,
90+
}),
91+
count_list = cjson.decode(cookie_counting_list)
92+
})
93+
break
94+
until true
95+
end
96+
97+
tl_ops_utils_func:set_ngx_req_return_ok(tl_ops_rt.ok, "success", res_data);
98+
end
99+
100+
return Router

0 commit comments

Comments
 (0)