Debian Codegraph @

test/functional/lua/deps.lua

raw
1 local cb = function(task)
2 task:insert_result('TOP', 1.0)
3 end
4
5 local cb_dep1 = function(task)
6 if task:get_symbol('TOP') then
7 task:insert_result('DEP1', 1.0)
8 end
9 end
10
11 local cb_gen = function(num)
12 local cb_dep = function(task)
13 if task:get_symbol('DEP' .. tostring(num)) then
14 task:insert_result('DEP' .. tostring(num + 1), 1.0)
15 end
16 end
17
18 return cb_dep
19 end
20
21 local id = rspamd_config:register_callback_symbol(1.0, cb)
22 rspamd_config:register_virtual_symbol('TOP', 1.0, id)
23
24 rspamd_config:register_symbol('DEP1', 1.0, cb_dep1)
25 rspamd_config:register_dependency('DEP1', 'TOP')
26
27 for i = 2, 10 do
28 rspamd_config:register_symbol('DEP' .. tostring(i), 1.0, cb_gen(i - 1))
29 rspamd_config:register_dependency('DEP' .. tostring(i), 'DEP' .. tostring(i - 1))
30 end