-
Couldn't load subscription status.
- Fork 3.9k
Add commands flags based on static map #4332
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
base: master
Are you sure you want to change the base?
Conversation
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.
Pull Request Overview
This PR introduces a command flags feature to the Jedis library by adding a static registry that maps Redis command names to their flags. The implementation retrieves command metadata from a Redis server and automatically generates flag mappings.
- Adds a code generator that connects to Redis servers to extract command metadata and generate flag mappings
- Implements a static command flags registry in
CommandObject.javawith comprehensive command coverage - Provides a
getFlags()method for runtime flag lookup with optimized memory usage through shared EnumSet instances
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/test/java/redis/clients/jedis/codegen/README.md | Documentation for the command flags registry generator tool |
| src/test/java/redis/clients/jedis/codegen/CommandFlagsRegistryGenerator.java | Code generator that retrieves Redis command metadata and updates the static registry |
| src/main/java/redis/clients/jedis/CommandObject.java | Core implementation with CommandFlag enum, static registry, and getFlags() method |
| pom.xml | Maven configuration to exclude code generators from test execution |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
src/test/java/redis/clients/jedis/codegen/CommandFlagsRegistryGenerator.java
Outdated
Show resolved
Hide resolved
src/test/java/redis/clients/jedis/codegen/CommandFlagsRegistryGenerator.java
Outdated
Show resolved
Hide resolved
src/test/java/redis/clients/jedis/codegen/CommandFlagsRegistryGenerator.java
Outdated
Show resolved
Hide resolved
e8157fa to
51c62d5
Compare
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.
Looks good.
For better traceability, I would suggest placing the generated code in a dedicated file.
Additionally, wrapping command metadata in in an interface (CommandMetadataRegistry.getFlag()) and providing it as an configurabel instance within CommandObject would be beneficial. The auto-generated registry can serve as the default, but users could replace it with a custom implementation if needed — for example, dynamically loading it from the server or providing a user-defined version.
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.
Adding the version of server - the generator running against- as part of generated content would be nice as well.
|
|
||
| public class CommandObject<T> { | ||
|
|
||
| /** |
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.
lets not do this and put everything into a seperate completely auto-generate class like CommandFlagRegistry or some provider class,, and use generated content at once without need of regex or any other searching/parsing. Then just consume it from CommandObject as needed.
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.
done
- Add new interface and move CommandFlag enum there - Generate StaticCommandFlagsRegistry instead of embedding generated code into CommandObject - Allow passing custom CommandFlagsRegistry to ClusterClientBuilder
Introduces command flags to simplify command routing.