mirror of
http://github.com/valkey-io/valkey
synced 2024-11-22 09:17:20 +00:00
f0e1edc273
Scope of the changes: - updated example modules to reference Valkey vs Redis in variable names - updated tests to use valkeymodule.h - updated vars in tests/modules to use valkey vs redis in variable names Summary of the testing: - ran make for all modules, loaded them into valkey-server and tested commands - ran make for test/modules - ran make test for the entire codebase --------- Signed-off-by: Dmitry Polyakovsky <dmitry.polyakovky@oracle.com> Co-authored-by: Dmitry Polyakovsky <dmitry.polyakovky@oracle.com>
39 lines
1.3 KiB
C
39 lines
1.3 KiB
C
#include "valkeymodule.h"
|
|
#include <strings.h>
|
|
|
|
/* Second module configs module, for testing.
|
|
* Need to make sure that multiple modules with configs don't interfere with each other */
|
|
int bool_config;
|
|
|
|
int getBoolConfigCommand(const char *name, void *privdata) {
|
|
VALKEYMODULE_NOT_USED(privdata);
|
|
if (!strcasecmp(name, "test")) {
|
|
return bool_config;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
int setBoolConfigCommand(const char *name, int new, void *privdata, ValkeyModuleString **err) {
|
|
VALKEYMODULE_NOT_USED(privdata);
|
|
VALKEYMODULE_NOT_USED(err);
|
|
if (!strcasecmp(name, "test")) {
|
|
bool_config = new;
|
|
return VALKEYMODULE_OK;
|
|
}
|
|
return VALKEYMODULE_ERR;
|
|
}
|
|
|
|
/* No arguments are expected */
|
|
int ValkeyModule_OnLoad(ValkeyModuleCtx *ctx, ValkeyModuleString **argv, int argc) {
|
|
VALKEYMODULE_NOT_USED(argv);
|
|
VALKEYMODULE_NOT_USED(argc);
|
|
if (ValkeyModule_Init(ctx, "configs", 1, VALKEYMODULE_APIVER_1) == VALKEYMODULE_ERR) return VALKEYMODULE_ERR;
|
|
|
|
if (ValkeyModule_RegisterBoolConfig(ctx, "test", 1, VALKEYMODULE_CONFIG_DEFAULT, getBoolConfigCommand, setBoolConfigCommand, NULL, &argc) == VALKEYMODULE_ERR) {
|
|
return VALKEYMODULE_ERR;
|
|
}
|
|
if (ValkeyModule_LoadConfigs(ctx) == VALKEYMODULE_ERR) {
|
|
return VALKEYMODULE_ERR;
|
|
}
|
|
return VALKEYMODULE_OK;
|
|
} |