1 2function mcp_config_pools() 3 local tbf_global = mcp.ratelim_global_tbf({limit = 25, fillrate = 5, tickrate = 500}) 4 return tbf_global 5end 6 7function mcp_config_routes(t) 8 -- limit is an arbitrary token count (bytes, requests, etc) 9 -- fillrate is tokens per tickrate 10 -- tickrate is milliseconds 11 local tbf = mcp.ratelim_tbf({limit = 50, fillrate = 4, tickrate = 500}) 12 13 local tbf_global = t 14 15 mcp.attach(mcp.CMD_MG, function(r) 16 if tbf(15) then 17 return "HD\r\n" 18 else 19 return "SERVER_ERROR slow down\r\n" 20 end 21 end) 22 23 mcp.attach(mcp.CMD_GET, function(r) 24 if tbf_global(10) then 25 return "END\r\n" 26 else 27 return "SERVER_ERROR global slow down\r\n" 28 end 29 end) 30end 31