1if reload_count == nil then
2    reload_count = 0
3end
4
5function mcp_config_pools()
6    mcp.backend_read_timeout(3)
7    mcp.backend_connect_timeout(5)
8    mcp.backend_flap_time(30) -- need a long time to reset the flap counter
9    mcp.backend_flap_backoff_ramp(1.2) -- very slow ramp
10    mcp.backend_retry_waittime(1) -- a quick retry for the test.
11    mcp.backend_failure_limit(2) -- reduced from default to speed up test.
12
13    reload_count = reload_count + 1
14    local arg = { label = 'b1', host = '127.0.0.1', port = 11799 }
15
16    if reload_count == 1 then
17        return mcp.pool({mcp.backend(arg)})
18    elseif reload_count == 2 then
19        mcp.backend_flap_time(2)
20        return mcp.pool({mcp.backend(arg)})
21    end
22end
23
24function mcp_config_routes(pool)
25    local fg = mcp.funcgen_new()
26    local handle = fg:new_handle(pool)
27    fg:ready({
28        f = function(rctx)
29            return function(r)
30                return rctx:enqueue_and_wait(r, handle)
31            end
32        end
33    })
34    mcp.attach(mcp.CMD_MG, fg)
35end
36