File: proxymatch.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 (32 lines) | stat: -rw-r--r-- 951 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
function mcp_config_pools()
    mcp.backend_connect_timeout(60)
    mcp.backend_read_timeout(60)
    mcp.backend_retry_timeout(60)
    local b1 = mcp.backend('b1', '127.0.0.1', 12171)
    return mcp.pool({b1})
end

function mcp_config_routes(p)
    local fg = mcp.funcgen_new()
    local h = fg:new_handle(p)
    fg:ready({
        n = "match", f = function(rctx)
            return function(r)
                local res = rctx:enqueue_and_wait(r, h)
                local match, token = r:match_res(res)
                if match then
                    mcp.log("match succeeded")
                else
                    if token then
                        mcp.log("match failed: " .. token)
                    else
                        mcp.log("match failed: no token")
                    end
                end
                return res
            end
        end
    })
    mcp.attach(mcp.CMD_MG, fg)
    mcp.attach(mcp.CMD_MS, fg)
end