Skip to content

Commit

Permalink
Update comments and swap API function parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
hwware committed Nov 5, 2024
1 parent 67e9459 commit 2d51ed9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions src/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -2254,16 +2254,17 @@ int moduleIsModuleCommand(void *module_handle, struct serverCommand *cmd) {
return (cp->module == module_handle);
}

/* ValkeyModule_UpdateRuntimeArgs can be used to update the values of module->loadmod
* so that the updated values can be saved into conf file once 'config rewrite' command
* is called
* One example can be found in file modules/moduleparameter.c
/* ValkeyModule_UpdateRuntimeArgs can be used to update the module argument values.
* The function parameter 'argc' indicates the number of updated arguments, and 'argv'
* represents the values of the updated arguments.
* Once 'CONFIG REWRITE' command is called, the updated argument values can be saved into conf file.
* One example can be found in file tests/modules/moduleparameter.c.
*
* Returns:
* - VALKEYMODULE_OK on successfully updating.
* - VALKEYMODULE_ERR on failure.
*/
int VM_UpdateRuntimeArgs(ValkeyModuleCtx *ctx, int argc, ValkeyModuleString **argv) {
int VM_UpdateRuntimeArgs(ValkeyModuleCtx *ctx, ValkeyModuleString **argv, int argc) {
if (!ctx->module->onload) {
return VALKEYMODULE_ERR;
}
Expand Down
2 changes: 1 addition & 1 deletion src/valkeymodule.h
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ VALKEYMODULE_API void (*ValkeyModule_SetModuleAttribs)(ValkeyModuleCtx *ctx, con
VALKEYMODULE_ATTR;
VALKEYMODULE_API int (*ValkeyModule_IsModuleNameBusy)(const char *name) VALKEYMODULE_ATTR;
VALKEYMODULE_API int (*ValkeyModule_WrongArity)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR;
VALKEYMODULE_API int (*ValkeyModule_UpdateRuntimeArgs)(ValkeyModuleCtx *ctx, int argc, ValkeyModuleString **argv) VALKEYMODULE_ATTR;
VALKEYMODULE_API int (*ValkeyModule_UpdateRuntimeArgs)(ValkeyModuleCtx *ctx, ValkeyModuleString **argv, int argc) VALKEYMODULE_ATTR;
VALKEYMODULE_API int (*ValkeyModule_ReplyWithLongLong)(ValkeyModuleCtx *ctx, long long ll) VALKEYMODULE_ATTR;
VALKEYMODULE_API int (*ValkeyModule_GetSelectedDb)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR;
VALKEYMODULE_API int (*ValkeyModule_SelectDb)(ValkeyModuleCtx *ctx, int newid) VALKEYMODULE_ATTR;
Expand Down
2 changes: 1 addition & 1 deletion tests/modules/moduleparameter.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <string.h>

int GET_HELLO(ValkeyModuleCtx *ctx, ValkeyModuleString **argv, int argc) {
ValkeyModule_UpdateRuntimeArgs(ctx, argc, argv);
ValkeyModule_UpdateRuntimeArgs(ctx, argv, argc);
return ValkeyModule_ReplyWithSimpleString(ctx, "Module runtime args test");
}

Expand Down

0 comments on commit 2d51ed9

Please sign in to comment.