Skip to content
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

Add feature flag to use RedisModule_* APIs as opt in and by default use ValkeyModule_* APIs #175

Open
1 of 7 tasks
KarthikSubbarao opened this issue Feb 17, 2025 · 0 comments

Comments

@KarthikSubbarao
Copy link
Member

KarthikSubbarao commented Feb 17, 2025

Currently, the valkeymodule-rs crate is using RedisModule_* APIs for all operations / interactions with the server. This works since internally in the Valkey, these APIs point to the equivalent ValkeyModule_* APIs.

For the official Valkey Modules, it would be more correct to use the ValkeyModule_* APIs by default.

We can support a new feature flag - use-redismodule-api and if a unofficial Valkey Module would like to, underneath, call the RedisModule_* APIs, they can build their module using this flag. Otherwise, by default, all interactions with the server will go through ValkeyModule_* APIs.

Use case:

Allow official Valkey Rust Modules to use ValkeyModule_* APIs by default.

And provide Unofficial Valkey Rust Modules a feature flag to opt-in to using RedisModule_ APIs.

Changes needed:

Support a use-redismodule-api feature flag and implement logic to support both cases.

This will need changes in the following places:

  • Add Feature Flag + support Module Init code using ValkeyModule_Init AND RedisModule_Init (when feature flag is enabled)
  • Module APIs. Example: ValkeyModule_Alloc. We can "easily" solve this by making all the VM_* APIs point to RM_* APIs when the feature flag is enabled.
  • Macros.
  • Callbacks - These are the extern "C" functions that will use either RedisModule_ or ValkeyModule_ function parameters.
  • Constants / Flags / Types - Currently, several structures (e.g. ValkeyString, Context, ValkeyKey, ValkeyType, StreamRecord, many more) are based on raw RedisModule_* structures, flags, constants. We can either switch completely to ValkeyModule_ [this is preferred] or maintain two versions [not preferred].
  • Example Modules
  • Tests
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

No branches or pull requests

1 participant