valkey-io / valkeymodule-rs

Rust valkey SDK for modules
BSD 3-Clause "New" or "Revised" License
32 stars 10 forks source link

Support for implementing Defrag Module type callback using existing Module APIs #98

Open KarthikSubbarao opened 1 month ago

KarthikSubbarao commented 1 month ago

The Module data types provide a callback for defragmentation and this is called when the active defrag is in progress.

For modules to implement the defrag callback, we will need wrapper functions in the valkeymodule-rs SDK written around the following existing Module APIs:

Higher priority:

ValkeyModule_DefragAlloc
ValkeyModule_DefragCursorSet
ValkeyModule_DefragCursorGet

Medium priority:

ValkeyModule_DefragShouldStop

Lower priority:

ValkeyModule_DefragValkeyModuleString
ValkeyModule_GetDbIdFromDefragCtx
ValkeyModule_RegisterDefragFunc
ValkeyModule_GetKeyNameFromDefragCtx

Example Valkey Module in C implementing the defragmentation callback: https://github.com/valkey-io/valkey/blob/4593dc2f059661e1c4eb43bba025f68948344228/tests/modules/defragtest.c#L143-L193

hahnandrew commented 2 weeks ago

Happy to pick this up 😄