File: proxyinternal.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 (39 lines) | stat: -rw-r--r-- 1,078 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
38
39
function mcp_config_pools()
    return true
end

function make_sub()
    local fg = mcp.funcgen_new()
    local h = fg:new_handle(mcp.internal_handler)
    fg:ready({ n = "subint", f = function(rctx)
        return function(r)
            return rctx:enqueue_and_wait(r, h)
        end
    end})
    return fg
end

function mcp_config_routes(zones)
    local fg = mcp.funcgen_new()
    local subfg = make_sub()
    local h = fg:new_handle(mcp.internal_handler)
    local hsub = fg:new_handle(subfg)
    fg:ready({ n = "internal", f = function(rctx)
        return function(r)
            local k = r:key()
            if string.find(k, "^/sub/") then
                return rctx:enqueue_and_wait(r, hsub)
            else
                if k == "log" then
                    local res = rctx:enqueue_and_wait(r, h)
                    mcp.log_req(r, res, "testing")
                    return res
                else
                    return rctx:enqueue_and_wait(r, h)
                end
            end
        end
    end})

    mcp.attach(mcp.CMD_ANY_STORAGE, fg)
end