Unverified Commit e875ff89 authored by guybe7's avatar guybe7 Committed by GitHub
Browse files

Add the deprecated_since field in command args of COMMAND DOCS (#10545)

Apparently, some modules can afford deprecating command arguments
(something that was never done in Redis, AFAIK), so in order to represent
this piece of information, we added the `deprecated_since` field to redisCommandArg
(in symmetry to the already existing `since` field).

This commit adds `const char *deprecated_since` to `RedisModuleCommandArg`,
which is technically a breaking change, but since 7.0 was not released yet, we decided to let it slide
parent bd8da0ca
...@@ -1931,6 +1931,7 @@ static struct redisCommandArg *moduleCopyCommandArgs(RedisModuleCommandArg *args ...@@ -1931,6 +1931,7 @@ static struct redisCommandArg *moduleCopyCommandArgs(RedisModuleCommandArg *args
if (arg->token) realargs[j].token = zstrdup(arg->token); if (arg->token) realargs[j].token = zstrdup(arg->token);
if (arg->summary) realargs[j].summary = zstrdup(arg->summary); if (arg->summary) realargs[j].summary = zstrdup(arg->summary);
if (arg->since) realargs[j].since = zstrdup(arg->since); if (arg->since) realargs[j].since = zstrdup(arg->since);
if (arg->deprecated_since) realargs[j].deprecated_since = zstrdup(arg->deprecated_since);
realargs[j].flags = moduleConvertArgFlags(arg->flags); realargs[j].flags = moduleConvertArgFlags(arg->flags);
if (arg->subargs) realargs[j].subargs = moduleCopyCommandArgs(arg->subargs, version); if (arg->subargs) realargs[j].subargs = moduleCopyCommandArgs(arg->subargs, version);
} }
...@@ -10941,6 +10942,7 @@ int moduleFreeCommand(struct RedisModule *module, struct redisCommand *cmd) { ...@@ -10941,6 +10942,7 @@ int moduleFreeCommand(struct RedisModule *module, struct redisCommand *cmd) {
} }
zfree((char *)cmd->summary); zfree((char *)cmd->summary);
zfree((char *)cmd->since); zfree((char *)cmd->since);
zfree((char *)cmd->deprecated_since);
zfree((char *)cmd->complexity); zfree((char *)cmd->complexity);
if (cmd->latency_histogram) { if (cmd->latency_histogram) {
hdr_close(cmd->latency_histogram); hdr_close(cmd->latency_histogram);
......
...@@ -322,6 +322,7 @@ typedef struct RedisModuleCommandArg { ...@@ -322,6 +322,7 @@ typedef struct RedisModuleCommandArg {
const char *summary; const char *summary;
const char *since; const char *since;
int flags; /* The REDISMODULE_CMD_ARG_* macros. */ int flags; /* The REDISMODULE_CMD_ARG_* macros. */
const char *deprecated_since;
struct RedisModuleCommandArg *subargs; struct RedisModuleCommandArg *subargs;
} RedisModuleCommandArg; } RedisModuleCommandArg;
......
...@@ -4317,6 +4317,7 @@ void addReplyCommandArgList(client *c, struct redisCommandArg *args, int num_arg ...@@ -4317,6 +4317,7 @@ void addReplyCommandArgList(client *c, struct redisCommandArg *args, int num_arg
if (args[j].token) maplen++; if (args[j].token) maplen++;
if (args[j].summary) maplen++; if (args[j].summary) maplen++;
if (args[j].since) maplen++; if (args[j].since) maplen++;
if (args[j].deprecated_since) maplen++;
if (args[j].flags) maplen++; if (args[j].flags) maplen++;
if (args[j].type == ARG_TYPE_ONEOF || args[j].type == ARG_TYPE_BLOCK) if (args[j].type == ARG_TYPE_ONEOF || args[j].type == ARG_TYPE_BLOCK)
maplen++; maplen++;
...@@ -4344,6 +4345,10 @@ void addReplyCommandArgList(client *c, struct redisCommandArg *args, int num_arg ...@@ -4344,6 +4345,10 @@ void addReplyCommandArgList(client *c, struct redisCommandArg *args, int num_arg
addReplyBulkCString(c, "since"); addReplyBulkCString(c, "since");
addReplyBulkCString(c, args[j].since); addReplyBulkCString(c, args[j].since);
} }
if (args[j].deprecated_since) {
addReplyBulkCString(c, "deprecated_since");
addReplyBulkCString(c, args[j].deprecated_since);
}
if (args[j].flags) { if (args[j].flags) {
addReplyBulkCString(c, "flags"); addReplyBulkCString(c, "flags");
addReplyFlagsForArg(c, args[j].flags); addReplyFlagsForArg(c, args[j].flags);
......
...@@ -2042,6 +2042,7 @@ typedef struct redisCommandArg { ...@@ -2042,6 +2042,7 @@ typedef struct redisCommandArg {
const char *summary; const char *summary;
const char *since; const char *since;
int flags; int flags;
const char *deprecated_since;
struct redisCommandArg *subargs; struct redisCommandArg *subargs;
/* runtime populated data */ /* runtime populated data */
int num_args; int num_args;
......
...@@ -175,6 +175,8 @@ class Argument(object): ...@@ -175,6 +175,8 @@ class Argument(object):
get_optional_desc_string(self.desc, "since"), get_optional_desc_string(self.desc, "since"),
_flags_code(), _flags_code(),
) )
if "deprecated_since" in self.desc:
s += ",.deprecated_since=\"%s\"" % self.desc["deprecated_since"]
if self.subargs: if self.subargs:
s += ",.subargs=%s" % self.subarg_table_name() s += ",.subargs=%s" % self.subarg_table_name()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment