valkey-bloom icon indicating copy to clipboard operation
valkey-bloom copied to clipboard

feat: Add command metadata and update tests

Open bravo1goingdark opened this issue 1 month ago • 0 comments

Add #[valkey_command] Metadata & KeySpecs for Bloom Filter Commands

This PR adds the #[valkey_command] macro to all Bloom Filter commands in src/lib.rs, enabling proper SetCommandInfo support through the valkeymodule-rs crate.
The macro now provides Valkey with complete metadata, including:

  • Command name
  • Flags
  • Arity
  • KeySpec definitions (key position, read/write semantics, key ranges)

As a result, COMMAND INFO BF.* now correctly reports the KeySpec metadata for each Bloom Filter command.


Changes Included

Added #[valkey_command] to all Bloom Filter commands:

  • BF.ADD
  • BF.MADD
  • BF.EXISTS
  • BF.MEXISTS
  • BF.CARD
  • BF.RESERVE
  • BF.INFO
  • BF.INSERT
  • BF.LOAD

Implemented complete KeySpecs for each command:

  • begin_search
  • find_keys
  • Key flags (rw, insert, update, access)

Updated tests in tests/test_bloom_command.py:

  • Adjusted expected arities
  • Added KeySpec validation checks

Minor cleanup:

  • Improved string formatting in:
    • src/bloom/data_type.rs
    • src/bloom/utils.rs

Notes / Limitations

The current version of valkeymodule-rs does not support argument metadata (args:) in SetCommandInfo.
Because of this limitation, this PR implements all supported metadata (KeySpecs), but cannot yet add full CLI argument autocomplete like the built-in SET command.

Once args support is added upstream in valkeymodule-rs, I can follow up with another PR to provide complete argument specifications for full autocomplete.


Verification

Example output of COMMAND INFO BF.ADD, showing that KeySpec metadata is now present:

KeySpec Output Screenshot

bravo1goingdark avatar Nov 23 '25 06:11 bravo1goingdark