Skip to content

Commit

Permalink
remove new command and relative functions
Browse files Browse the repository at this point in the history
  • Loading branch information
hwware committed Oct 16, 2024
1 parent 50aa816 commit 5c63d6d
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 80 deletions.
32 changes: 0 additions & 32 deletions src/commands/module-set-argument.json

This file was deleted.

35 changes: 0 additions & 35 deletions src/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -13046,22 +13046,11 @@ int VM_RdbSave(ValkeyModuleCtx *ctx, ValkeyModuleRdbStream *stream, int flags) {
return VALKEYMODULE_OK;
}


void updateModuleRunTimeArgument(struct ValkeyModule *module, void **argv, int argc) {
module->loadmod->argv = argc ? zmalloc(sizeof(robj *) * argc) : NULL;
module->loadmod->argc = argc;
for (int i = 0; i < argc; i++) {
module->loadmod->argv[i] = argv[i];
incrRefCount(module->loadmod->argv[i]);
}
}

/* MODULE command.
*
* MODULE LIST
* MODULE LOAD <path> [args...]
* MODULE LOADEX <path> [[CONFIG NAME VALUE] [CONFIG NAME VALUE]] [ARGS ...]
* MODULE SET-ARGUMENT <name> [args...]
* MODULE UNLOAD <name>
*/
void moduleCommand(client *c) {
Expand All @@ -13075,8 +13064,6 @@ void moduleCommand(client *c) {
" Load a module library from <path>, passing to it any optional arguments.",
"LOADEX <path> [[CONFIG NAME VALUE] [CONFIG NAME VALUE]] [ARGS ...]",
" Load a module library from <path>, while passing it module configurations and optional arguments.",
"SET-ARGUMENT <name> [<arg> ...]",
" Set module arguments to new values during runtime.",
"UNLOAD <name>",
" Unload a module.",
NULL};
Expand Down Expand Up @@ -13123,28 +13110,6 @@ void moduleCommand(client *c) {
}
} else if (!strcasecmp(subcmd, "list") && c->argc == 2) {
addReplyLoadedModules(c);
} else if (!strcasecmp(subcmd, "set-argument") && c->argc >= 3) {
struct ValkeyModule *module = dictFetchValue(modules, c->argv[2]->ptr);
if (module != NULL) {
for (int i = 0; i < module->loadmod->argc; i++) {
decrRefCount(module->loadmod->argv[i]);
}
zfree(module->loadmod->argv);
robj **argv = NULL;
int argc = 0;

if (c->argc > 3) {
argc = c->argc - 3;
argv = &c->argv[3];
}
updateModuleRunTimeArgument(module, (void **)argv, argc);

addReply(c, shared.ok);
} else {
addReplyError(c, "Error set arguments for module: no such module with that name ");
serverLog(LL_WARNING, "Error set arguments for module %s: no such module with that name",
(sds)c->argv[2]->ptr);
}
} else {
addReplySubcommandSyntaxError(c);
return;
Expand Down
13 changes: 0 additions & 13 deletions tests/unit/moduleapi/moduleconfigs.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -246,19 +246,6 @@ start_server {tags {"modules"}} {
}
}

test {Module Set-Argument command work} {
r module load $testmoduleparameter

set t [r module list]
set modulename [lmap x [r module list] {dict get $x name}]
assert_not_equal [lsearch $modulename myhello] -1
string match "" [lmap x [r module list] {dict get $x args}]
r module set-argument myhello 1 2 3
r config rewrite
restart_server 0 true false
string match "1 2 3" [lmap x [r module list] {dict get $x args}]
}

}


Expand Down

0 comments on commit 5c63d6d

Please sign in to comment.