Skip to content

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

@KarthikSubbarao

Description

@KarthikSubbarao

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions