1-- get some information about the test being run from an external file
2-- so we can modify ourselves.
3local mode = dofile("/tmp/proxytagmode.lua")
4
5function mcp_config_pools()
6    -- we only ever need the one backend for this test.
7    -- we're explicitly not testing for changes in the backend, but that
8    -- routes are overwritten properly.
9    local be = mcp.backend('be', '127.0.0.1', 12050)
10    local p = mcp.pool({ be })
11    return p
12end
13
14function mcp_config_routes(p)
15    if mode == "start" then
16        local fg = mcp.funcgen_new()
17        local h = fg:new_handle(p)
18        fg:ready({
19            f = function(rctx)
20                return function(r)
21                    return rctx:enqueue_and_wait(r, h)
22                end
23            end
24        })
25        -- one without tag
26        mcp.attach(mcp.CMD_MG, fg)
27        -- no listener on a
28        mcp.attach(mcp.CMD_MG, function(r) return "SERVER_ERROR tag A\r\n" end, "a")
29        -- listener on b
30        mcp.attach(mcp.CMD_MG, function(r) return "SERVER_ERROR tag B\r\n" end, "b")
31        -- extra listener.
32        mcp.attach(mcp.CMD_MG, function(r) return "SERVER_ERROR tag CCCC\r\n" end, "cccc")
33    end
34    -- TODO: reload to replace functions, ensure change.
35    -- TODO: mcp.CMD_ANY_STORAGE on reload
36    -- TODO: mcp.CMD_ANY_STORAGE and then replace a single CMD_MG
37end
38