1function mcp_config_pools() 2 -- print("CONFIG GARBAGE: " .. collectgarbage("count")) 3 local b1 = mcp.backend('b1', '127.0.0.1', 12101) 4 return mcp.pool({b1}) 5end 6 7-- the same fgen should be fine for the whole test. it doesn't matter how 8-- complicated each individual fgen is, just that we're stacking them and 9-- routing them. 10-- Even with just one item linked they'll have all of the request/result/etc 11-- objects referenced. 12function basic_fgen(p) 13 local fgen = mcp.funcgen_new() 14 local h = fgen:new_handle(p) 15 fgen:ready({ n = "foo", f = function(rctx) 16 return function(r) 17 local k = r:key() 18 19 if string.find(k, "collect$") then 20 collectgarbage() 21 collectgarbage() 22 local mem = collectgarbage("count") 23 return "SERVER_ERROR " .. tostring(mem) .. "\r\n" 24 elseif string.find(k, "go$") then 25 return rctx:enqueue_and_wait(r, h) 26 else 27 return "SERVER_ERROR unknown key: " .. k .. "\r\n" 28 end 29 end 30 end}) 31 return fgen 32end 33 34function mcp_config_routes(p) 35 local map = { 36 ["one"] = basic_fgen(p), 37 ["two"] = basic_fgen(basic_fgen(p)), 38 ["three"] = basic_fgen(basic_fgen(basic_fgen(p))), 39 } 40 -- "leak" an fgen on purpose. 41 -- this gets a cleanup routine through the GC instead of directly during 42 -- dereferencing. 43 basic_fgen(p) 44 45 -- defaults are fine. "prefix/etc" 46 local router = mcp.router_new({ 47 map = map, 48 }) 49 50 mcp.attach(mcp.CMD_MG, router) 51end 52