diff options
author | dormando <dormando@rydia.net> | 2022-03-01 12:51:47 -0800 |
---|---|---|
committer | dormando <dormando@rydia.net> | 2022-03-01 12:51:47 -0800 |
commit | fa745db8fffe7d13438fe2437bdf8fcb1372bc96 (patch) | |
tree | 15bd7946d2d9ac6631c635f5c7ac12228e078f0b /proxy.h | |
parent | 2a903f04d1b395cd60c1b7357a9b733e19eb7973 (diff) | |
download | memcached-fa745db8fffe7d13438fe2437bdf8fcb1372bc96.tar.gz |
proxy: hacky method of supporting noreply/quiet
avoids sending the response to the client, in most cases. works by
stripping the noreply status from the request before sending it along,
so the proxy itself knows when to move the request forward.
has sharp edges:
- only looking at the request object that's actually sent to the
backend, instead of the request object that created the coroutine.
- overriding tokens in lua to re-set the noreply mode would break the
protocol.
So this change helps us validate the feature but solidifying it requires
moving it to the "edges" of processing; before the coroutine and after
any command assembly (or within the command assembly).
Diffstat (limited to 'proxy.h')
-rw-r--r-- | proxy.h | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -131,7 +131,6 @@ enum proxy_defines { enum proxy_cmd_types { CMD_TYPE_GENERIC = 0, CMD_TYPE_GET, // get/gets/gat/gats - CMD_TYPE_UPDATE, // add/set/cas/prepend/append/replace CMD_TYPE_META, // m*'s. }; @@ -273,6 +272,7 @@ struct mcp_parser_s { uint32_t klen; // length of key. uint16_t tokens[PARSER_MAX_TOKENS]; // offsets for start of each token bool has_space; // a space was found after the last byte parsed. + bool noreply; // if quiet/noreply mode is set. union { struct mcp_parser_meta_s meta; } t; @@ -355,15 +355,22 @@ struct proxy_event_thread_s { struct proxy_tunables tunables; // periodically copied from main ctx }; +enum mcp_resp_mode { + RESP_MODE_NORMAL = 0, + RESP_MODE_NOREPLY, + RESP_MODE_METAQUIET +}; + #define RESP_CMD_MAX 8 typedef struct { mcmc_resp_t resp; struct timeval start; // start time inherited from paired request - char cmd[RESP_CMD_MAX+1]; // until we can reverse CMD_*'s to strings directly. - int status; // status code from mcmc_read() char *buf; // response line + potentially value. size_t blen; // total size of the value to read. + int status; // status code from mcmc_read() int bread; // amount of bytes read into value so far. + char cmd[RESP_CMD_MAX+1]; // until we can reverse CMD_*'s to strings directly. + enum mcp_resp_mode mode; // reply mode (for noreply fixing) } mcp_resp_t; // re-cast an io_pending_t into this more descriptive structure. |