-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Command info module API #10108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Command info module API #10108
Conversation
The keyspec API is not yet released and there is a plan to change it in redis#10108, which is going to be included in RC2. Therefore, we hide it in RC1 to avoid introducing a breaking change in RC2.
|
@redis/core-team please approve the new module API |
Two new tests: 1. A command without keyspecs. Check that the legacy triple remains and that a keyspec is autogenerated from the legacy triple. 2. A command with only a keyword-based keyspec. This spec cases the legacy triple to be overwritten with (0,0,0) and sets movablekeys. In all tests, check movablekeys, which is overridden based on keyspecs.
|
@zuiderkwast @oranagra I've pushed a private commit with an alternative here: This seems a bit more straight forward to me. Callers need to pass an extra |
|
it is slightly more verbose to the user to use, but i guess that's a drop in the ocean compared to the declarative part of the command metadata, and indeed more inline with other APIs (in which we ask the user to explicitly set a version field in a struct), and of course avoids the static function and special naming. |
@yossigo OK. I agree it's more strait forward. In that case, isn't it better to put the version field back inside the info struct, like in the other APIs, and make it a struct pointer? The version macro can expand to a pointer to a static constant struct defined in redismodule.h. WDYT? One more reason to get rid of the if (RedisModule_SetCommandInfo != NULL) {
RedisModule_SetCommandInfo(cmd, info);
} |
|
putting this as a first first member of the info struct means we can't extend it with more |
We can if it's a pointer to a version struct. |
|
@zuiderkwast I thought about that, but wasn't very happy with defining a static variable in |
|
we actually already have these. |
|
Exactly, the events are all static const. They end up in every object file, in modules which don't use events. Also, all the API functions are global pointers. Most of them are not used by most of the modules. |
|
@zuiderkwast @oranagra Good points, so the pointer approach makes sense. |
itamarhaber
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM && !CR
Adds RM_SetCommandInfo, allowing modules to provide the following command info:
This information affects the output of
COMMAND,COMMAND INFOandCOMMAND DOCS, Cluster, ACL and is used to filter commands with the wrong number of arguments before the call reaches the module code.The recently added API functions for key specs (never released) are removed.
This work is based on some commits in #9656 and then rewritten to the declarative style as discussed in #9944.
Fixes #9944.
A minimalist example would look like so:
Notes: