-
Notifications
You must be signed in to change notification settings - Fork 927
Add internal linked list to the Module API #2675
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
base: unstable
Are you sure you want to change the base?
Conversation
This commit introduces the support for modules to use the internal singly linked list implementation in their implementations. This will be required by the future Lua scripting engine module. New API functions: - `ValkeyModule_ListCreate()`: Create a new list with automatic memory management - `ValkeyModule_ListFree()`: Explicitly free a list - `ValkeyModule_ListLength()`: Get the number of elements in a list - `ValkeyModule_ListAddToTail()`: Add elements to the end of the list - `ValkeyModule_ListGetIter()`: Create an iterator for list traversal - `ValkeyModule_ListIterNext()`: Get the next element during iteration - `ValkeyModule_ListReleaseIter()`: Free the iterator Signed-off-by: Ricardo Dias <[email protected]>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## unstable #2675 +/- ##
============================================
- Coverage 72.18% 72.17% -0.01%
============================================
Files 128 128
Lines 70994 71029 +35
============================================
+ Hits 51246 51268 +22
- Misses 19748 19761 +13
🚀 New features to boost your workflow:
|
@rjd15372 trying to understand the motivation better. Is this because the standard C does not include any existing list implementation or is it intended for the auto memory collecting during context destruction? |
The main reason is the former. Without this PR I would need to add a simple linked list implementation to the lua module. Which I don't strongly opposed if folks don't like having this API in the module API. |
It's nice to provide convenience datastructures for modules to use. We already have the module Dict (which is actually a radix tree) that modules can use. I have some concerns though:
With this in mind, I think it's better to start with an implementation of a linked list in the Lua module itself. What more is needed for the Lua module? |
| What more is needed for the Lua module? There are a few other changes to the module API, for which I'll open separate PRs to make it easy to review and discuss. |
OK, but it's good to have an overview so we can see the full picture. Is it more internal datatypes or other kinds of module API changes? |
it's just three new API functions: VALKEYMODULE_API int (*ValkeyModule_ACLCheckCommandPermissionsForContextUser)(ValkeyModuleCtx *ctx,
ValkeyModuleString **argv,
int argc) VALKEYMODULE_ATTR;
VALKEYMODULE_API ValkeyModuleCallReply *(*ValkeyModule_CallArgv)(ValkeyModuleCtx *ctx,
ValkeyModuleString **argv,
size_t argc,
ValkeyModuleCallCommandFlags flags)VALKEYMODULE_ATTR;
VALKEYMODULE_API int (*ValkeyModule_ReplyWithCustomErrorFormat)(ValkeyModuleCtx *ctx, int update_error_stats, const char *fmt, ...) VALKEYMODULE_ATTR; |
This commit introduces the support for modules to use the internal singly linked list implementation in their implementations.
This will be required by the future Lua scripting engine module.
New API functions:
ValkeyModule_ListCreate()
: Create a new list with automatic memory managementValkeyModule_ListFree()
: Explicitly free a listValkeyModule_ListLength()
: Get the number of elements in a listValkeyModule_ListAddToTail()
: Add elements to the end of the listValkeyModule_ListGetIter()
: Create an iterator for list traversalValkeyModule_ListIterNext()
: Get the next element during iterationValkeyModule_ListReleaseIter()
: Free the iterator