Repository navigation
(rust): Add an INFO section enum matching the other GLIDE clients #7366
Description
Describe the feature
Add an INFO section enum to the Rust client (rust/, crate valkey-glide) that matches the other GLIDE clients.
Today, ServerManagementCommands::info_sections (rust/src/commands/server_management.rs) accepts any &[S] where S: ToValkeyArgs, so callers pass free-form strings:
let info = client.info_sections(&["persistence"]).await?;The other GLIDE clients have a section enum with the same members, sorted alphabetically since #7364:
| Client | Type |
|---|---|
| Go | constants.Section |
| Java | InfoOptions.Section |
| Node | InfoOptions |
| Python | InfoSection |
Their members: all, clients, cluster, cluster_info (Valkey 9.1.0+), commandstats, cpu, default, errorstats, everything, keyspace, latencystats, memory, modules, persistence, replication, sentinel, server, stats.
Use Case
- Discoverability: IDE completion and the generated docs would list the valid sections, with a doc comment for each, including which Valkey version added it (e.g.
cluster_info). - Correctness: a typo such as
"persistance"compiles, and the server quietly returns an empty reply for it. An enum variant can't be misspelled. - Consistency: Rust code would read the same way as the other GLIDE clients (
InfoSection::Persistence, like Python'sInfoSection.PERSISTENCE).
Proposed Solution
- Add an
InfoSectionenum torust/src/commands/options.rs, which mirrors Python'score_options. Include all 18 sections, in alphabetical order, with doc comments matching the other clients. - Implement
ToValkeyArgsfor it, asExpireOptionand the other option enums there do, writing the lowercase section name. info_sectionsis already generic overToValkeyArgs, so it would accept&[InfoSection::Persistence]with no signature change, and string callers keep working. Keeping strings also covers module-defined sections, which the enum can't list. Decide whether that's the intended API, or whetherinfo_sectionsshould accept onlyInfoSection, which would be a breaking change, acceptable while the crate is in 0.x preview.- Use the enum in the Rust tests (e.g.
get_infoandinfo_returns_expected_fieldsinrust/tests/). - Consider doing this together with (rust): Typed multi-node server commands fail on cluster clients #7362, which changes the return types of the typed
INFOmethods.
Other Information
Found while working on #7199 (#7364), which added cluster_info to the Go, Java, Node and Python section enums. Rust had nothing to add it to.
Acknowledgements
- I may be able to implement this feature request
- This feature might incur a breaking change
Client version used
valkey-glide (Rust) 0.9.0
Environment details (OS name and version, etc.)
⚪ Not applicable
Activity
feat(rust): add InfoSection enum matching other GLIDE clients
feat(rust): add InfoSection enum matching other GLIDE clients