diff options
author | dormando <dormando@rydia.net> | 2022-09-23 12:30:03 -0700 |
---|---|---|
committer | dormando <dormando@rydia.net> | 2022-09-27 12:38:25 -0700 |
commit | 1ba54b05a4a23d1acd85b5c14384ac8cbaed8478 (patch) | |
tree | 934fcdaca39a8cc7935c5e204fa6d36e129a0a49 | |
parent | 725954d3a37ff0596f4a8e53c5746eec3a30166d (diff) | |
download | memcached-1ba54b05a4a23d1acd85b5c14384ac8cbaed8478.tar.gz |
proxy: add mcp.await FASTGOOD flag
returns early on a hit, else waits for N non-error responses.
-rw-r--r-- | proxy.h | 1 | ||||
-rw-r--r-- | proxy_await.c | 11 | ||||
-rw-r--r-- | proxy_lua.c | 1 |
3 files changed, 13 insertions, 0 deletions
@@ -444,6 +444,7 @@ enum mcp_await_e { AWAIT_ANY, // any response, including errors, AWAIT_OK, // any non-error response AWAIT_FIRST, // return the result from the first pool + AWAIT_FASTGOOD, // returns on first hit or majority non-error }; int mcplib_await(lua_State *L); int mcplib_await_run(conn *c, mc_resp *resp, lua_State *L, int coro_ref); diff --git a/proxy_await.c b/proxy_await.c index d60f380..8eb5aa6 100644 --- a/proxy_await.c +++ b/proxy_await.c @@ -49,6 +49,7 @@ int mcplib_await(lua_State *L) { case AWAIT_ANY: case AWAIT_OK: case AWAIT_FIRST: + case AWAIT_FASTGOOD: break; default: proxy_lua_error(L, "invalid type argument tp mcp.await"); @@ -286,6 +287,16 @@ int mcplib_await_return(io_pending_proxy_t *p) { valid = false; } break; + case AWAIT_FASTGOOD: + if (p->client_resp->status == MCMC_OK) { + // End early on a hit. + if (p->client_resp->resp.code != MCMC_CODE_END) { + aw->wait_for = 0; + } else { + is_good = true; + } + } + break; } if (is_good) { diff --git a/proxy_lua.c b/proxy_lua.c index 40936ec..9d2358f 100644 --- a/proxy_lua.c +++ b/proxy_lua.c @@ -859,6 +859,7 @@ static void proxy_register_defines(lua_State *L) { X(AWAIT_ANY); X(AWAIT_OK); X(AWAIT_FIRST); + X(AWAIT_FASTGOOD); CMD_FIELDS #undef X } |