Skip to content

Conversation

@bravo1goingdark
Copy link

@bravo1goingdark bravo1goingdark commented Nov 23, 2025

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

This commit adds the `valkey_command` macro to all the bloom filter
commands in `src/lib.rs`. This macro provides metadata about the
commands, such as their arity, flags, and key specifications. This
is important for Valkey to properly handle the commands.

The tests in `tests/test_bloom_command.py` have been updated to
reflect the new command arities and to add a new test that verifies
that the key specifications are present for the commands that have
them.

Finally, some string formatting in `src/bloom/data_type.rs` and
`src/bloom/utils.rs` has been updated to use the more modern and
efficient f-string style formatting.

Signed-off-by: Ashutosh Kumar <[email protected]>
@bravo1goingdark bravo1goingdark marked this pull request as ready for review November 23, 2025 07:03
@bravo1goingdark bravo1goingdark marked this pull request as draft November 23, 2025 07:29
Signed-off-by: Ashutosh Kumar <[email protected]>
@bravo1goingdark bravo1goingdark marked this pull request as ready for review November 23, 2025 08:07
"bloom",
]
commands: [
["BF.ADD", bloom_add_command, "write fast deny-oom", 1, 1, 1, "fast write bloom"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this remove the bloom and other ACL categories from all the commands? Can you run the integration tests to validate if this passes?

You can check the valkey_module! macro to see how the command creation works in there. Specifically, how the ACL category is set through it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants