forked from memcached/memcached
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
give request contexts the ability to time out on wait operations. this allows moving along the logic without cancelling in flight requests or resetting backends.
- Loading branch information
Showing
6 changed files
with
218 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
function mcp_config_pools() | ||
local b1 = mcp.backend('b1', '127.0.0.1', 12141) | ||
local b2 = mcp.backend('b2', '127.0.0.1', 12142) | ||
local b3 = mcp.backend('b3', '127.0.0.1', 12143) | ||
|
||
return { | ||
z1 = mcp.pool({b1}), | ||
z2 = mcp.pool({b2}), | ||
z3 = mcp.pool({b3}) | ||
} | ||
end | ||
|
||
function cond_timeout(p) | ||
local fgen = mcp.funcgen_new() | ||
local near = fgen:new_handle(p.z1) | ||
local far = { fgen:new_handle(p.z2), | ||
fgen:new_handle(p.z3) } | ||
|
||
local all = { near, far[1], far[2] } | ||
|
||
fgen:ready({ n = "cond_timeout", f = function(rctx) | ||
return function(r) | ||
rctx:enqueue(r, near) | ||
local done, timeout = rctx:wait_cond_timeout(1, mcp.WAIT_GOOD, 0.5) | ||
|
||
if timeout then | ||
rctx:enqueue(r, far) | ||
local done = rctx:wait_cond(1, mcp.WAIT_GOOD) | ||
for x=1,#all do | ||
local res = rctx:res_any(all[x]) | ||
if res then | ||
return res | ||
end | ||
end | ||
return "SERVER_ERROR no responses\r\n" | ||
else | ||
return rctx:res_any(near) | ||
end | ||
end | ||
end}) | ||
return fgen | ||
end | ||
|
||
-- TODO: different cond_timeout test with 2/3 instead of 1 | ||
|
||
function mcp_config_routes(p) | ||
local map = { | ||
["cond_timeout"] = cond_timeout(p), | ||
} | ||
|
||
-- defaults are fine. "prefix/etc" | ||
local router = mcp.router_new({ | ||
map = map, | ||
}) | ||
|
||
mcp.attach(mcp.CMD_MG, router) | ||
end |
Oops, something went wrong.