File: proxytags.lua

package info (click to toggle)
memcached 1.6.39-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,320 kB
  • sloc: ansic: 62,281; perl: 12,500; sh: 4,569; makefile: 468; python: 402; xml: 59
file content (37 lines) | stat: -rw-r--r-- 1,345 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
-- get some information about the test being run from an external file
-- so we can modify ourselves.
local mode = dofile("/tmp/proxytagmode.lua")

function mcp_config_pools()
    -- we only ever need the one backend for this test.
    -- we're explicitly not testing for changes in the backend, but that
    -- routes are overwritten properly.
    local be = mcp.backend('be', '127.0.0.1', 12050)
    local p = mcp.pool({ be })
    return p
end

function mcp_config_routes(p)
    if mode == "start" then
        local fg = mcp.funcgen_new()
        local h = fg:new_handle(p)
        fg:ready({
            f = function(rctx)
                return function(r)
                    return rctx:enqueue_and_wait(r, h)
                end
            end
        })
        -- one without tag
        mcp.attach(mcp.CMD_MG, fg)
        -- no listener on a
        mcp.attach(mcp.CMD_MG, function(r) return "SERVER_ERROR tag A\r\n" end, "a")
        -- listener on b
        mcp.attach(mcp.CMD_MG, function(r) return "SERVER_ERROR tag B\r\n" end, "b")
        -- extra listener.
        mcp.attach(mcp.CMD_MG, function(r) return "SERVER_ERROR tag CCCC\r\n" end, "cccc")
    end
    -- TODO: reload to replace functions, ensure change.
    -- TODO: mcp.CMD_ANY_STORAGE on reload
    -- TODO: mcp.CMD_ANY_STORAGE and then replace a single CMD_MG
end