-
Notifications
You must be signed in to change notification settings - Fork 21
Description
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